zip_money 1.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/Gemfile +7 -0
- data/Gemfile.lock +69 -0
- data/README.md +128 -0
- data/Rakefile +8 -0
- data/docs/Address.md +15 -0
- data/docs/Authority.md +9 -0
- data/docs/CaptureChargeRequest.md +8 -0
- data/docs/Charge.md +17 -0
- data/docs/ChargeCollection.md +8 -0
- data/docs/ChargeOrder.md +11 -0
- data/docs/ChargesApi.md +307 -0
- data/docs/Checkout.md +18 -0
- data/docs/CheckoutConfiguration.md +8 -0
- data/docs/CheckoutFeatures.md +8 -0
- data/docs/CheckoutFeaturesTokenisation.md +8 -0
- data/docs/CheckoutOrder.md +13 -0
- data/docs/CheckoutsApi.md +119 -0
- data/docs/CreateChargeRequest.md +14 -0
- data/docs/CreateCheckoutRequest.md +13 -0
- data/docs/CreateCheckoutRequestFeatures.md +8 -0
- data/docs/CreateCheckoutRequestFeaturesTokenisation.md +8 -0
- data/docs/CreateRefundRequest.md +11 -0
- data/docs/CreateTokenRequest.md +8 -0
- data/docs/Customer.md +15 -0
- data/docs/CustomersApi.md +96 -0
- data/docs/ErrorResponse.md +8 -0
- data/docs/ErrorResponseError.md +10 -0
- data/docs/ErrorResponseErrorDetails.md +9 -0
- data/docs/InlineResponse200.md +8 -0
- data/docs/Metadata.md +7 -0
- data/docs/OrderItem.md +16 -0
- data/docs/OrderShipping.md +10 -0
- data/docs/OrderShippingTracking.md +10 -0
- data/docs/Refund.md +13 -0
- data/docs/RefundsApi.md +181 -0
- data/docs/SettlementsApi.md +96 -0
- data/docs/Shopper.md +17 -0
- data/docs/ShopperStatistics.md +16 -0
- data/docs/Token.md +11 -0
- data/docs/TokensApi.md +66 -0
- data/lib/zip_money.rb +68 -0
- data/lib/zip_money/api/charges_api.rb +301 -0
- data/lib/zip_money/api/checkouts_api.rb +120 -0
- data/lib/zip_money/api/customers_api.rb +116 -0
- data/lib/zip_money/api/refunds_api.rb +181 -0
- data/lib/zip_money/api/settlements_api.rb +116 -0
- data/lib/zip_money/api/tokens_api.rb +70 -0
- data/lib/zip_money/api_client.rb +386 -0
- data/lib/zip_money/api_error.rb +31 -0
- data/lib/zip_money/configuration.rb +238 -0
- data/lib/zip_money/models/address.rb +413 -0
- data/lib/zip_money/models/authority.rb +235 -0
- data/lib/zip_money/models/capture_charge_request.rb +206 -0
- data/lib/zip_money/models/charge.rb +369 -0
- data/lib/zip_money/models/charge_collection.rb +188 -0
- data/lib/zip_money/models/charge_order.rb +250 -0
- data/lib/zip_money/models/checkout.rb +344 -0
- data/lib/zip_money/models/checkout_configuration.rb +187 -0
- data/lib/zip_money/models/checkout_features.rb +181 -0
- data/lib/zip_money/models/checkout_features_tokenisation.rb +184 -0
- data/lib/zip_money/models/checkout_order.rb +299 -0
- data/lib/zip_money/models/create_charge_request.rb +289 -0
- data/lib/zip_money/models/create_checkout_request.rb +272 -0
- data/lib/zip_money/models/create_checkout_request_features.rb +181 -0
- data/lib/zip_money/models/create_checkout_request_features_tokenisation.rb +189 -0
- data/lib/zip_money/models/create_refund_request.rb +246 -0
- data/lib/zip_money/models/create_token_request.rb +186 -0
- data/lib/zip_money/models/customer.rb +310 -0
- data/lib/zip_money/models/error_response.rb +181 -0
- data/lib/zip_money/models/error_response_error.rb +211 -0
- data/lib/zip_money/models/error_response_error_details.rb +190 -0
- data/lib/zip_money/models/inline_response_200.rb +188 -0
- data/lib/zip_money/models/metadata.rb +172 -0
- data/lib/zip_money/models/order_item.rb +333 -0
- data/lib/zip_money/models/order_shipping.rb +200 -0
- data/lib/zip_money/models/order_shipping_tracking.rb +247 -0
- data/lib/zip_money/models/refund.rb +252 -0
- data/lib/zip_money/models/shopper.rb +339 -0
- data/lib/zip_money/models/shopper_statistics.rb +295 -0
- data/lib/zip_money/models/token.rb +228 -0
- data/lib/zip_money/version.rb +8 -0
- data/spec/api/charges_api_spec.rb +114 -0
- data/spec/api/checkouts_api_spec.rb +54 -0
- data/spec/api/customers_api_spec.rb +51 -0
- data/spec/api/refunds_api_spec.rb +67 -0
- data/spec/api/settlements_api_spec.rb +51 -0
- data/spec/api/tokens_api_spec.rb +41 -0
- data/spec/api_client_spec.rb +219 -0
- data/spec/configuration_spec.rb +50 -0
- data/spec/models/address_spec.rb +77 -0
- data/spec/models/authority_spec.rb +45 -0
- data/spec/models/capture_charge_request_spec.rb +35 -0
- data/spec/models/charge_collection_spec.rb +35 -0
- data/spec/models/charge_order_spec.rb +53 -0
- data/spec/models/charge_spec.rb +93 -0
- data/spec/models/checkout_configuration_spec.rb +35 -0
- data/spec/models/checkout_features_spec.rb +35 -0
- data/spec/models/checkout_features_tokenisation_spec.rb +35 -0
- data/spec/models/checkout_order_spec.rb +65 -0
- data/spec/models/checkout_spec.rb +103 -0
- data/spec/models/create_charge_request_spec.rb +75 -0
- data/spec/models/create_checkout_request_features_spec.rb +35 -0
- data/spec/models/create_checkout_request_features_tokenisation_spec.rb +35 -0
- data/spec/models/create_checkout_request_spec.rb +69 -0
- data/spec/models/create_refund_request_spec.rb +53 -0
- data/spec/models/create_token_request_spec.rb +35 -0
- data/spec/models/customer_spec.rb +81 -0
- data/spec/models/error_response_error_details_spec.rb +41 -0
- data/spec/models/error_response_error_spec.rb +47 -0
- data/spec/models/error_response_spec.rb +35 -0
- data/spec/models/inline_response_200_spec.rb +35 -0
- data/spec/models/metadata_spec.rb +29 -0
- data/spec/models/order_item_spec.rb +87 -0
- data/spec/models/order_shipping_spec.rb +47 -0
- data/spec/models/order_shipping_tracking_spec.rb +47 -0
- data/spec/models/refund_spec.rb +65 -0
- data/spec/models/shopper_spec.rb +92 -0
- data/spec/models/shopper_statistics_spec.rb +86 -0
- data/spec/models/token_spec.rb +52 -0
- data/spec/payload_helper.rb +96 -0
- data/spec/spec_helper.rb +104 -0
- data/zip_money.gemspec +38 -0
- metadata +380 -0
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
#Merchant API
|
|
2
|
+
#ZipMoney Merchant API Initial build
|
|
3
|
+
#zipMoney Merchant API version: 2017-03-01
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
require 'spec_helper'
|
|
7
|
+
require 'json'
|
|
8
|
+
|
|
9
|
+
# Unit tests for ZipMoney::RefundsApi
|
|
10
|
+
|
|
11
|
+
# Please update as you see appropriate
|
|
12
|
+
describe 'RefundsApi' do
|
|
13
|
+
before do
|
|
14
|
+
# run before each test
|
|
15
|
+
@instance = ZipMoney::RefundsApi.new
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
after do
|
|
19
|
+
# run after each test
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
describe 'test an instance of RefundsApi' do
|
|
23
|
+
it 'should create an instact of RefundsApi' do
|
|
24
|
+
expect(@instance).to be_instance_of(ZipMoney::RefundsApi)
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
# unit tests for refunds_create
|
|
29
|
+
# Create a refund
|
|
30
|
+
# Creates a refund for a previously authorised or captured charge. See #model:xWJer4QQyRumRi9LD for more information. This endpoint will return 201 or otherwise 402 if unable to perform the refund. | Error code | Description | |------------------------------------|--------------------------------------------------------------------------------------------------| | amount_invalid | The refund amount is greater than the remaining captured total | | invalid_state | 1. The charge is already fully refunded |
|
|
31
|
+
# @param [Hash] opts the optional parameters
|
|
32
|
+
# @option opts [CreateRefundRequest] :body
|
|
33
|
+
# @option opts [String] :idempotency_key The unique idempotency key.
|
|
34
|
+
# @return [Refund]
|
|
35
|
+
describe 'refunds_create test' do
|
|
36
|
+
it "should work" do
|
|
37
|
+
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
# unit tests for refunds_list
|
|
42
|
+
# List refunds
|
|
43
|
+
# List all refunds
|
|
44
|
+
# @param [Hash] opts the optional parameters
|
|
45
|
+
# @option opts [String] :charge_id
|
|
46
|
+
# @option opts [Integer] :skip Number of items to skip when paging
|
|
47
|
+
# @option opts [Integer] :limit Number of items to retrieve when paging
|
|
48
|
+
# @return [Array<InlineResponse200>]
|
|
49
|
+
describe 'refunds_list test' do
|
|
50
|
+
it "should work" do
|
|
51
|
+
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
# unit tests for refunds_retrieve
|
|
56
|
+
# Retrieve a refund
|
|
57
|
+
# Retrieves details of a specific refund
|
|
58
|
+
# @param id The id of the refund
|
|
59
|
+
# @param [Hash] opts the optional parameters
|
|
60
|
+
# @return [Refund]
|
|
61
|
+
describe 'refunds_retrieve test' do
|
|
62
|
+
it "should work" do
|
|
63
|
+
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
end
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
#Merchant API
|
|
2
|
+
#ZipMoney Merchant API Initial build
|
|
3
|
+
#zipMoney Merchant API version: 2017-03-01
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
require 'spec_helper'
|
|
7
|
+
require 'json'
|
|
8
|
+
|
|
9
|
+
# Unit tests for ZipMoney::SettlementsApi
|
|
10
|
+
|
|
11
|
+
# Please update as you see appropriate
|
|
12
|
+
describe 'SettlementsApi' do
|
|
13
|
+
before do
|
|
14
|
+
# run before each test
|
|
15
|
+
@instance = ZipMoney::SettlementsApi.new
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
after do
|
|
19
|
+
# run after each test
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
describe 'test an instance of SettlementsApi' do
|
|
23
|
+
it 'should create an instact of SettlementsApi' do
|
|
24
|
+
expect(@instance).to be_instance_of(ZipMoney::SettlementsApi)
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
# unit tests for settlements_get
|
|
29
|
+
# Retrieve a settlement
|
|
30
|
+
# Retrieves the full transactional details of a settlement.
|
|
31
|
+
# @param id The settlement id
|
|
32
|
+
# @param [Hash] opts the optional parameters
|
|
33
|
+
# @return [nil]
|
|
34
|
+
describe 'settlements_get test' do
|
|
35
|
+
it "should work" do
|
|
36
|
+
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
# unit tests for settlements_list
|
|
41
|
+
# List settlements
|
|
42
|
+
# This endpoint will allow a merchant to view the settlements which have occured. To view detailed transaction information for a specific settlement you can use the Retrieve a settlement endpoint.
|
|
43
|
+
# @param [Hash] opts the optional parameters
|
|
44
|
+
# @return [nil]
|
|
45
|
+
describe 'settlements_list test' do
|
|
46
|
+
it "should work" do
|
|
47
|
+
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
end
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
#Merchant API
|
|
2
|
+
#ZipMoney Merchant API Initial build
|
|
3
|
+
#zipMoney Merchant API version: 2017-03-01
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
require 'spec_helper'
|
|
7
|
+
require 'json'
|
|
8
|
+
|
|
9
|
+
# Unit tests for ZipMoney::TokensApi
|
|
10
|
+
|
|
11
|
+
# Please update as you see appropriate
|
|
12
|
+
describe 'TokensApi' do
|
|
13
|
+
before do
|
|
14
|
+
# run before each test
|
|
15
|
+
@instance = ZipMoney::TokensApi.new
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
after do
|
|
19
|
+
# run after each test
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
describe 'test an instance of TokensApi' do
|
|
23
|
+
it 'should create an instact of TokensApi' do
|
|
24
|
+
expect(@instance).to be_instance_of(ZipMoney::TokensApi)
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
# unit tests for tokens_create
|
|
29
|
+
# Create token
|
|
30
|
+
# Tokenises a zip account allowing a charge to be performed at a later date without direct customer involvement. In order to create a token you will first need to request customer approval by implementing one of the online checkout flows. The checkout id will then be provided as the authority when tokenising. | Error code | Description | |------------------------------------|--------------------------------------------------------------------------------------------------| | account_inoperative | The account is in arrears or closed and cannot be charged | | account_locked | The account is locked |
|
|
31
|
+
# @param [Hash] opts the optional parameters
|
|
32
|
+
# @option opts [CreateTokenRequest] :body
|
|
33
|
+
# @option opts [String] :idempotency_key The unique idempotency key.
|
|
34
|
+
# @return [Token]
|
|
35
|
+
describe 'tokens_create test' do
|
|
36
|
+
it "should work" do
|
|
37
|
+
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
end
|
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
#Merchant API
|
|
2
|
+
#ZipMoney Merchant API Initial build
|
|
3
|
+
#zipMoney Merchant API version: 2017-03-01
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
require 'spec_helper'
|
|
7
|
+
|
|
8
|
+
describe ZipMoney::ApiClient do
|
|
9
|
+
context 'initialization' do
|
|
10
|
+
context 'URL stuff' do
|
|
11
|
+
context 'host' do
|
|
12
|
+
it 'removes http from host' do
|
|
13
|
+
ZipMoney.configure { |c| c.host = 'http://example.com' }
|
|
14
|
+
expect(ZipMoney::Configuration.default.host).to eq('example.com')
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
it 'removes https from host' do
|
|
18
|
+
ZipMoney.configure { |c| c.host = 'https://wookiee.com' }
|
|
19
|
+
expect(ZipMoney::ApiClient.default.config.host).to eq('wookiee.com')
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
it 'removes trailing path from host' do
|
|
23
|
+
ZipMoney.configure { |c| c.host = 'hobo.com/v4' }
|
|
24
|
+
expect(ZipMoney::Configuration.default.host).to eq('hobo.com')
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
context 'base_path' do
|
|
29
|
+
it "prepends a slash to base_path" do
|
|
30
|
+
ZipMoney.configure { |c| c.base_path = 'v4/dog' }
|
|
31
|
+
expect(ZipMoney::Configuration.default.base_path).to eq('/v4/dog')
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
it "doesn't prepend a slash if one is already there" do
|
|
35
|
+
ZipMoney.configure { |c| c.base_path = '/v4/dog' }
|
|
36
|
+
expect(ZipMoney::Configuration.default.base_path).to eq('/v4/dog')
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
it "ends up as a blank string if nil" do
|
|
40
|
+
ZipMoney.configure { |c| c.base_path = nil }
|
|
41
|
+
expect(ZipMoney::Configuration.default.base_path).to eq('')
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
describe "params_encoding in #build_request" do
|
|
48
|
+
let(:config) { ZipMoney::Configuration.new }
|
|
49
|
+
let(:api_client) { ZipMoney::ApiClient.new(config) }
|
|
50
|
+
|
|
51
|
+
it "defaults to nil" do
|
|
52
|
+
expect(ZipMoney::Configuration.default.params_encoding).to eq(nil)
|
|
53
|
+
expect(config.params_encoding).to eq(nil)
|
|
54
|
+
|
|
55
|
+
request = api_client.build_request(:get, '/test')
|
|
56
|
+
expect(request.options[:params_encoding]).to eq(nil)
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
it "can be customized" do
|
|
60
|
+
config.params_encoding = :multi
|
|
61
|
+
request = api_client.build_request(:get, '/test')
|
|
62
|
+
expect(request.options[:params_encoding]).to eq(:multi)
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
describe "timeout in #build_request" do
|
|
67
|
+
let(:config) { ZipMoney::Configuration.new }
|
|
68
|
+
let(:api_client) { ZipMoney::ApiClient.new(config) }
|
|
69
|
+
|
|
70
|
+
it "defaults to 0" do
|
|
71
|
+
expect(ZipMoney::Configuration.default.timeout).to eq(0)
|
|
72
|
+
expect(config.timeout).to eq(0)
|
|
73
|
+
|
|
74
|
+
request = api_client.build_request(:get, '/test')
|
|
75
|
+
expect(request.options[:timeout]).to eq(0)
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
it "can be customized" do
|
|
79
|
+
config.timeout = 100
|
|
80
|
+
request = api_client.build_request(:get, '/test')
|
|
81
|
+
expect(request.options[:timeout]).to eq(100)
|
|
82
|
+
end
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
describe "#deserialize" do
|
|
86
|
+
it "handles Array<Integer>" do
|
|
87
|
+
api_client = ZipMoney::ApiClient.new
|
|
88
|
+
headers = {'Content-Type' => 'application/json'}
|
|
89
|
+
response = double('response', headers: headers, body: '[12, 34]')
|
|
90
|
+
data = api_client.deserialize(response, 'Array<Integer>')
|
|
91
|
+
expect(data).to be_instance_of(Array)
|
|
92
|
+
expect(data).to eq([12, 34])
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
it "handles Array<Array<Integer>>" do
|
|
96
|
+
api_client = ZipMoney::ApiClient.new
|
|
97
|
+
headers = {'Content-Type' => 'application/json'}
|
|
98
|
+
response = double('response', headers: headers, body: '[[12, 34], [56]]')
|
|
99
|
+
data = api_client.deserialize(response, 'Array<Array<Integer>>')
|
|
100
|
+
expect(data).to be_instance_of(Array)
|
|
101
|
+
expect(data).to eq([[12, 34], [56]])
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
it "handles Hash<String, String>" do
|
|
105
|
+
api_client = ZipMoney::ApiClient.new
|
|
106
|
+
headers = {'Content-Type' => 'application/json'}
|
|
107
|
+
response = double('response', headers: headers, body: '{"message": "Hello"}')
|
|
108
|
+
data = api_client.deserialize(response, 'Hash<String, String>')
|
|
109
|
+
expect(data).to be_instance_of(Hash)
|
|
110
|
+
expect(data).to eq({:message => 'Hello'})
|
|
111
|
+
end
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
describe "#object_to_hash" do
|
|
115
|
+
it "ignores nils and includes empty arrays" do
|
|
116
|
+
# uncomment below to test object_to_hash for model
|
|
117
|
+
#api_client = ZipMoney::ApiClient.new
|
|
118
|
+
#_model = ZipMoney::ModelName.new
|
|
119
|
+
# update the model attribute below
|
|
120
|
+
#_model.id = 1
|
|
121
|
+
# update the expected value (hash) below
|
|
122
|
+
#expected = {id: 1, name: '', tags: []}
|
|
123
|
+
#expect(api_client.object_to_hash(_model)).to eq(expected)
|
|
124
|
+
end
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
describe "#build_collection_param" do
|
|
128
|
+
let(:param) { ['aa', 'bb', 'cc'] }
|
|
129
|
+
let(:api_client) { ZipMoney::ApiClient.new }
|
|
130
|
+
|
|
131
|
+
it "works for csv" do
|
|
132
|
+
expect(api_client.build_collection_param(param, :csv)).to eq('aa,bb,cc')
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
it "works for ssv" do
|
|
136
|
+
expect(api_client.build_collection_param(param, :ssv)).to eq('aa bb cc')
|
|
137
|
+
end
|
|
138
|
+
|
|
139
|
+
it "works for tsv" do
|
|
140
|
+
expect(api_client.build_collection_param(param, :tsv)).to eq("aa\tbb\tcc")
|
|
141
|
+
end
|
|
142
|
+
|
|
143
|
+
it "works for pipes" do
|
|
144
|
+
expect(api_client.build_collection_param(param, :pipes)).to eq('aa|bb|cc')
|
|
145
|
+
end
|
|
146
|
+
|
|
147
|
+
it "works for multi" do
|
|
148
|
+
expect(api_client.build_collection_param(param, :multi)).to eq(['aa', 'bb', 'cc'])
|
|
149
|
+
end
|
|
150
|
+
|
|
151
|
+
it "fails for invalid collection format" do
|
|
152
|
+
expect(proc { api_client.build_collection_param(param, :INVALID) }).to raise_error(RuntimeError, 'unknown collection format: :INVALID')
|
|
153
|
+
end
|
|
154
|
+
end
|
|
155
|
+
|
|
156
|
+
describe "#json_mime?" do
|
|
157
|
+
let(:api_client) { ZipMoney::ApiClient.new }
|
|
158
|
+
|
|
159
|
+
it "works" do
|
|
160
|
+
expect(api_client.json_mime?(nil)).to eq false
|
|
161
|
+
expect(api_client.json_mime?('')).to eq false
|
|
162
|
+
|
|
163
|
+
expect(api_client.json_mime?('application/json')).to eq true
|
|
164
|
+
expect(api_client.json_mime?('application/json; charset=UTF8')).to eq true
|
|
165
|
+
expect(api_client.json_mime?('APPLICATION/JSON')).to eq true
|
|
166
|
+
|
|
167
|
+
expect(api_client.json_mime?('application/xml')).to eq false
|
|
168
|
+
expect(api_client.json_mime?('text/plain')).to eq false
|
|
169
|
+
expect(api_client.json_mime?('application/jsonp')).to eq false
|
|
170
|
+
end
|
|
171
|
+
end
|
|
172
|
+
|
|
173
|
+
describe "#select_header_accept" do
|
|
174
|
+
let(:api_client) { ZipMoney::ApiClient.new }
|
|
175
|
+
|
|
176
|
+
it "works" do
|
|
177
|
+
expect(api_client.select_header_accept(nil)).to be_nil
|
|
178
|
+
expect(api_client.select_header_accept([])).to be_nil
|
|
179
|
+
|
|
180
|
+
expect(api_client.select_header_accept(['application/json'])).to eq('application/json')
|
|
181
|
+
expect(api_client.select_header_accept(['application/xml', 'application/json; charset=UTF8'])).to eq('application/json; charset=UTF8')
|
|
182
|
+
expect(api_client.select_header_accept(['APPLICATION/JSON', 'text/html'])).to eq('APPLICATION/JSON')
|
|
183
|
+
|
|
184
|
+
expect(api_client.select_header_accept(['application/xml'])).to eq('application/xml')
|
|
185
|
+
expect(api_client.select_header_accept(['text/html', 'application/xml'])).to eq('text/html,application/xml')
|
|
186
|
+
end
|
|
187
|
+
end
|
|
188
|
+
|
|
189
|
+
describe "#select_header_content_type" do
|
|
190
|
+
let(:api_client) { ZipMoney::ApiClient.new }
|
|
191
|
+
|
|
192
|
+
it "works" do
|
|
193
|
+
expect(api_client.select_header_content_type(nil)).to eq('application/json')
|
|
194
|
+
expect(api_client.select_header_content_type([])).to eq('application/json')
|
|
195
|
+
|
|
196
|
+
expect(api_client.select_header_content_type(['application/json'])).to eq('application/json')
|
|
197
|
+
expect(api_client.select_header_content_type(['application/xml', 'application/json; charset=UTF8'])).to eq('application/json; charset=UTF8')
|
|
198
|
+
expect(api_client.select_header_content_type(['APPLICATION/JSON', 'text/html'])).to eq('APPLICATION/JSON')
|
|
199
|
+
expect(api_client.select_header_content_type(['application/xml'])).to eq('application/xml')
|
|
200
|
+
expect(api_client.select_header_content_type(['text/plain', 'application/xml'])).to eq('text/plain')
|
|
201
|
+
end
|
|
202
|
+
end
|
|
203
|
+
|
|
204
|
+
describe "#sanitize_filename" do
|
|
205
|
+
let(:api_client) { ZipMoney::ApiClient.new }
|
|
206
|
+
|
|
207
|
+
it "works" do
|
|
208
|
+
expect(api_client.sanitize_filename('sun')).to eq('sun')
|
|
209
|
+
expect(api_client.sanitize_filename('sun.gif')).to eq('sun.gif')
|
|
210
|
+
expect(api_client.sanitize_filename('../sun.gif')).to eq('sun.gif')
|
|
211
|
+
expect(api_client.sanitize_filename('/var/tmp/sun.gif')).to eq('sun.gif')
|
|
212
|
+
expect(api_client.sanitize_filename('./sun.gif')).to eq('sun.gif')
|
|
213
|
+
expect(api_client.sanitize_filename('..\sun.gif')).to eq('sun.gif')
|
|
214
|
+
expect(api_client.sanitize_filename('\var\tmp\sun.gif')).to eq('sun.gif')
|
|
215
|
+
expect(api_client.sanitize_filename('c:\var\tmp\sun.gif')).to eq('sun.gif')
|
|
216
|
+
expect(api_client.sanitize_filename('.\sun.gif')).to eq('sun.gif')
|
|
217
|
+
end
|
|
218
|
+
end
|
|
219
|
+
end
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
#Merchant API
|
|
2
|
+
#ZipMoney Merchant API Initial build
|
|
3
|
+
#zipMoney Merchant API version: 2017-03-01
|
|
4
|
+
|
|
5
|
+
require 'spec_helper'
|
|
6
|
+
|
|
7
|
+
describe ZipMoney::Configuration do
|
|
8
|
+
let(:config) { ZipMoney::Configuration.default }
|
|
9
|
+
|
|
10
|
+
before(:each) do
|
|
11
|
+
# uncomment below to setup host and base_path
|
|
12
|
+
#require 'URI'
|
|
13
|
+
uri = URI.parse("https://api.sandbox.zipmoney.com.au/merchant/v1")
|
|
14
|
+
|
|
15
|
+
ZipMoney.configure do |c|
|
|
16
|
+
c.host = uri.host
|
|
17
|
+
c.base_path = uri.path
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
describe '#base_url' do
|
|
22
|
+
it 'should have the default value' do
|
|
23
|
+
# uncomment below to test default value of the base path
|
|
24
|
+
expect(config.base_url).to eq("https://api.sandbox.zipmoney.com.au/merchant/v1")
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
# it 'should remove trailing slashes' do
|
|
28
|
+
# [nil, '', '/', '//'].each do |base_path|
|
|
29
|
+
# config.base_path = base_path
|
|
30
|
+
# # uncomment below to test trailing slashes
|
|
31
|
+
# expect(config.base_url).to eq("https://api.sandbox.zipmoney.com.au")
|
|
32
|
+
# end
|
|
33
|
+
# end
|
|
34
|
+
|
|
35
|
+
it 'should set the sandbox environment' do
|
|
36
|
+
config.environment = :sandbox
|
|
37
|
+
# uncomment below to test trailing slashes
|
|
38
|
+
expect(config.base_url).to eq("https://api.sandbox.zipmoney.com.au/merchant/v1")
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
it 'should set the production environment' do
|
|
42
|
+
config.environment = :production
|
|
43
|
+
# uncomment below to test trailing slashes
|
|
44
|
+
expect(config.base_url).to eq("https://api.zipmoney.com.au/merchant/v1")
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
end
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
#Merchant API
|
|
2
|
+
#ZipMoney Merchant API Initial build
|
|
3
|
+
#zipMoney Merchant API version: 2017-03-01
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
require 'spec_helper'
|
|
7
|
+
require 'json'
|
|
8
|
+
require 'date'
|
|
9
|
+
|
|
10
|
+
# Unit tests for ZipMoney::Address
|
|
11
|
+
|
|
12
|
+
# Please update as you see appropriate
|
|
13
|
+
describe 'Address' do
|
|
14
|
+
before do
|
|
15
|
+
# run before each test
|
|
16
|
+
@instance = ZipMoney::Address.new
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
after do
|
|
20
|
+
# run after each test
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
describe 'test an instance of Address' do
|
|
24
|
+
it 'should create an instact of Address' do
|
|
25
|
+
expect(@instance).to be_instance_of(ZipMoney::Address)
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
describe 'test attribute "line1"' do
|
|
29
|
+
it 'should work' do
|
|
30
|
+
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
describe 'test attribute "line2"' do
|
|
35
|
+
it 'should work' do
|
|
36
|
+
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
describe 'test attribute "city"' do
|
|
41
|
+
it 'should work' do
|
|
42
|
+
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
describe 'test attribute "state"' do
|
|
47
|
+
it 'should work' do
|
|
48
|
+
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
describe 'test attribute "postal_code"' do
|
|
53
|
+
it 'should work' do
|
|
54
|
+
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
describe 'test attribute "country"' do
|
|
59
|
+
it 'should work' do
|
|
60
|
+
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
describe 'test attribute "first_name"' do
|
|
65
|
+
it 'should work' do
|
|
66
|
+
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
describe 'test attribute "last_name"' do
|
|
71
|
+
it 'should work' do
|
|
72
|
+
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
end
|
|
77
|
+
|