Sha256: c1e40eef236a31d5b3935a7d3e80d55c70de11a4874fda6eb3aa36d43a270e43
Contents?: true
Size: 1.29 KB
Versions: 2
Compression:
Stored size: 1.29 KB
Contents
require 'pcp-server-ruby-sdk' class CommerceCaseApiExample attr_accessor :client, :merchant_id, :commerce_case_id def initialize(config) @client = CommerceCaseApiClient.new(config) @merchant_id = ENV['MERCHANT_ID'] @commerce_case_id = ENV['COMMERCE_CASE_ID'] end def run_post_one payload = {} res = @client.create_commerce_case_request(@merchant_id, payload) puts JSON.pretty_generate(res) end def run_get_all query = GetCommerceCasesQuery.new query.set_offset(2) query.set_size(2) res = @client.get_commerce_cases_request(@merchant_id, query) puts JSON.pretty_generate(res) end def run_get_one res = @client.get_commerce_case_request(@merchant_id, @commerce_case_id) puts JSON.pretty_generate(res) end def run_update_one get_one_response = @client.get_commerce_case_request(@merchant_id, @commerce_case_id) raise 'Customer not found' unless get_one_response.customer raise 'Billing address not found' unless get_one_response.customer.billing_address modified_customer = get_one_response.customer.dup modified_customer.billing_address.city = 'New York' res = @client.update_commerce_case_request(@merchant_id, @commerce_case_id, modified_customer) puts JSON.pretty_generate(res) end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
pcp-server-ruby-sdk-0.0.6 | example-app/commerce_case_api_example.rb |
pcp-server-ruby-sdk-0.1.0 | example-app/commerce_case_api_example.rb |