bitpesa-sdk 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/Gemfile +1 -0
- data/Gemfile.lock +5 -4
- data/README.md +19 -7
- data/docs/Sender.md +1 -0
- data/docs/SenderResponse.md +1 -0
- data/docs/SenderResponseExisting.md +8 -0
- data/docs/SenderResponseMeta.md +8 -0
- data/docs/SendersApi.md +2 -0
- data/docs/Transaction.md +1 -0
- data/docs/TransactionResponse.md +1 -0
- data/docs/TransactionResponseExisting.md +9 -0
- data/docs/TransactionResponseMeta.md +8 -0
- data/docs/TransactionsApi.md +2 -0
- data/example/client.rb +47 -9
- data/lib/bitpesa-sdk.rb +4 -0
- data/lib/bitpesa-sdk/api/senders_api.rb +3 -0
- data/lib/bitpesa-sdk/api/transactions_api.rb +3 -0
- data/lib/bitpesa-sdk/api_client.rb +1 -1
- data/lib/bitpesa-sdk/models/sender.rb +12 -2
- data/lib/bitpesa-sdk/models/sender_response.rb +13 -4
- data/lib/bitpesa-sdk/models/sender_response_existing.rb +195 -0
- data/lib/bitpesa-sdk/models/sender_response_meta.rb +195 -0
- data/lib/bitpesa-sdk/models/transaction.rb +11 -1
- data/lib/bitpesa-sdk/models/transaction_response.rb +13 -4
- data/lib/bitpesa-sdk/models/transaction_response_existing.rb +204 -0
- data/lib/bitpesa-sdk/models/transaction_response_meta.rb +195 -0
- data/lib/bitpesa-sdk/version.rb +1 -1
- data/spec/api/account_debits_api_spec.rb +17 -15
- data/spec/api/account_validation_api_spec.rb +10 -10
- data/spec/api/accounts_api_spec.rb +13 -13
- data/spec/api/api_logs_api_spec.rb +15 -11
- data/spec/api/currency_info_api_spec.rb +13 -13
- data/spec/api/documents_api_spec.rb +16 -14
- data/spec/api/logs_api_spec.rb +15 -11
- data/spec/api/payment_methods_api_spec.rb +11 -11
- data/spec/api/payout_methods_api_spec.rb +55 -11
- data/spec/api/recipients_api_spec.rb +23 -18
- data/spec/api/senders_api_spec.rb +26 -21
- data/spec/api/transactions_api_spec.rb +48 -22
- data/spec/api/webhooks_api_spec.rb +20 -20
- data/spec/api_client_spec.rb +52 -90
- data/spec/configuration_spec.rb +13 -13
- data/spec/models/account_meta_spec.rb +5 -6
- data/spec/models/api_log_spec.rb +16 -17
- data/spec/models/currency_spec.rb +27 -16
- data/spec/models/debit_request_spec.rb +9 -34
- data/spec/models/debit_spec.rb +42 -13
- data/spec/models/document_request_spec.rb +9 -56
- data/spec/models/document_spec.rb +71 -8
- data/spec/models/pagination_spec.rb +33 -10
- data/spec/models/payin_method_details_mobile_spec.rb +6 -7
- data/spec/models/payin_method_details_ngn_bank_spec.rb +5 -6
- data/spec/models/payment_method_spec.rb +19 -14
- data/spec/models/payout_method_details_balance_spec.rb +5 -6
- data/spec/models/payout_method_details_ghs_bank_spec.rb +8 -9
- data/spec/models/payout_method_details_iban_spec.rb +9 -10
- data/spec/models/payout_method_details_mad_cash_spec.rb +15 -24
- data/spec/models/payout_method_details_mobile_spec.rb +7 -8
- data/spec/models/payout_method_details_ngn_bank_spec.rb +9 -14
- data/spec/models/payout_method_details_xof_mobile_spec.rb +8 -13
- data/spec/models/payout_method_request_spec.rb +6 -19
- data/spec/models/payout_method_response_spec.rb +6 -19
- data/spec/models/payout_method_spec.rb +18 -19
- data/spec/models/recipient_request_spec.rb +6 -25
- data/spec/models/recipient_response_spec.rb +6 -103
- data/spec/models/recipient_spec.rb +127 -8
- data/spec/models/sender_request_spec.rb +9 -104
- data/spec/models/sender_response_existing_spec.rb +41 -0
- data/spec/models/sender_response_meta_spec.rb +41 -0
- data/spec/models/sender_response_spec.rb +8 -103
- data/spec/models/sender_spec.rb +167 -8
- data/spec/models/transaction_request_spec.rb +9 -16
- data/spec/models/transaction_response_existing_spec.rb +47 -0
- data/spec/models/transaction_response_meta_spec.rb +41 -0
- data/spec/models/transaction_response_spec.rb +8 -75
- data/spec/models/transaction_spec.rb +84 -13
- data/spec/models/transaction_traits_spec.rb +6 -7
- data/spec/models/webhook_definition_request_spec.rb +6 -19
- data/spec/models/webhook_log_metadata_request_spec.rb +10 -11
- data/spec/models/webhook_log_metadata_response_spec.rb +10 -11
- data/spec/models/webhook_log_metadata_spec.rb +17 -18
- data/spec/models/webhook_log_spec.rb +13 -14
- data/spec/models/webhook_spec.rb +7 -8
- data/spec/spec_helper.rb +4 -4
- metadata +19 -309
- data/example/.LICENSE.un~ +0 -0
- data/example/.client.rb.un~ +0 -0
- data/spec/api/transaction_requests_api_spec.rb +0 -76
- data/spec/models/account_base_spec.rb +0 -48
- data/spec/models/api_log_base_spec.rb +0 -90
- data/spec/models/body_spec.rb +0 -58
- data/spec/models/currency_base_spec.rb +0 -84
- data/spec/models/debit_base_spec.rb +0 -66
- data/spec/models/debit_error_response_spec.rb +0 -72
- data/spec/models/debit_valid_response_spec.rb +0 -72
- data/spec/models/default_document_spec.rb +0 -94
- data/spec/models/default_recipient_spec.rb +0 -60
- data/spec/models/default_sender_spec.rb +0 -142
- data/spec/models/default_webhook_spec.rb +0 -60
- data/spec/models/document_base_spec.rb +0 -88
- data/spec/models/document_error_response_spec.rb +0 -94
- data/spec/models/document_valid_response_spec.rb +0 -94
- data/spec/models/full_invalid_transaction_request_spec.rb +0 -78
- data/spec/models/full_invalid_transaction_spec.rb +0 -66
- data/spec/models/full_valid_transaction_request_spec.rb +0 -66
- data/spec/models/full_valid_transaction_spec.rb +0 -60
- data/spec/models/inline_response_200_10_spec.rb +0 -42
- data/spec/models/inline_response_200_11_spec.rb +0 -48
- data/spec/models/inline_response_200_12_spec.rb +0 -42
- data/spec/models/inline_response_200_13_spec.rb +0 -48
- data/spec/models/inline_response_200_14_spec.rb +0 -42
- data/spec/models/inline_response_200_15_spec.rb +0 -48
- data/spec/models/inline_response_200_16_spec.rb +0 -48
- data/spec/models/inline_response_200_17_spec.rb +0 -48
- data/spec/models/inline_response_200_18_spec.rb +0 -42
- data/spec/models/inline_response_200_19_spec.rb +0 -48
- data/spec/models/inline_response_200_1_spec.rb +0 -48
- data/spec/models/inline_response_200_20_spec.rb +0 -42
- data/spec/models/inline_response_200_21_object_spec.rb +0 -42
- data/spec/models/inline_response_200_21_spec.rb +0 -42
- data/spec/models/inline_response_200_22_object_spec.rb +0 -42
- data/spec/models/inline_response_200_22_spec.rb +0 -42
- data/spec/models/inline_response_200_23_object_spec.rb +0 -42
- data/spec/models/inline_response_200_23_spec.rb +0 -48
- data/spec/models/inline_response_200_24_spec.rb +0 -42
- data/spec/models/inline_response_200_25_spec.rb +0 -42
- data/spec/models/inline_response_200_26_spec.rb +0 -42
- data/spec/models/inline_response_200_27_spec.rb +0 -48
- data/spec/models/inline_response_200_28_spec.rb +0 -42
- data/spec/models/inline_response_200_29_spec.rb +0 -48
- data/spec/models/inline_response_200_2_object_spec.rb +0 -42
- data/spec/models/inline_response_200_2_spec.rb +0 -42
- data/spec/models/inline_response_200_30_spec.rb +0 -42
- data/spec/models/inline_response_200_31_spec.rb +0 -48
- data/spec/models/inline_response_200_32_spec.rb +0 -42
- data/spec/models/inline_response_200_33_spec.rb +0 -48
- data/spec/models/inline_response_200_34_spec.rb +0 -42
- data/spec/models/inline_response_200_35_spec.rb +0 -48
- data/spec/models/inline_response_200_36_spec.rb +0 -48
- data/spec/models/inline_response_200_37_spec.rb +0 -48
- data/spec/models/inline_response_200_38_spec.rb +0 -42
- data/spec/models/inline_response_200_39_spec.rb +0 -48
- data/spec/models/inline_response_200_3_spec.rb +0 -48
- data/spec/models/inline_response_200_40_spec.rb +0 -42
- data/spec/models/inline_response_200_4_object_spec.rb +0 -42
- data/spec/models/inline_response_200_4_spec.rb +0 -42
- data/spec/models/inline_response_200_5_spec.rb +0 -42
- data/spec/models/inline_response_200_6_spec.rb +0 -42
- data/spec/models/inline_response_200_7_spec.rb +0 -48
- data/spec/models/inline_response_200_8_spec.rb +0 -42
- data/spec/models/inline_response_200_9_spec.rb +0 -48
- data/spec/models/inline_response_200_spec.rb +0 -48
- data/spec/models/inline_response_201_10_spec.rb +0 -42
- data/spec/models/inline_response_201_11_spec.rb +0 -42
- data/spec/models/inline_response_201_1_spec.rb +0 -42
- data/spec/models/inline_response_201_2_spec.rb +0 -42
- data/spec/models/inline_response_201_3_spec.rb +0 -42
- data/spec/models/inline_response_201_4_spec.rb +0 -42
- data/spec/models/inline_response_201_5_spec.rb +0 -42
- data/spec/models/inline_response_201_6_spec.rb +0 -42
- data/spec/models/inline_response_201_7_spec.rb +0 -42
- data/spec/models/inline_response_201_8_spec.rb +0 -42
- data/spec/models/inline_response_201_9_spec.rb +0 -42
- data/spec/models/inline_response_201_spec.rb +0 -42
- data/spec/models/inline_response_400_1_spec.rb +0 -48
- data/spec/models/inline_response_400_spec.rb +0 -48
- data/spec/models/inline_response_422_10_spec.rb +0 -42
- data/spec/models/inline_response_422_11_spec.rb +0 -42
- data/spec/models/inline_response_422_12_spec.rb +0 -42
- data/spec/models/inline_response_422_13_spec.rb +0 -42
- data/spec/models/inline_response_422_14_spec.rb +0 -42
- data/spec/models/inline_response_422_1_meta_spec.rb +0 -42
- data/spec/models/inline_response_422_1_object_spec.rb +0 -42
- data/spec/models/inline_response_422_1_spec.rb +0 -42
- data/spec/models/inline_response_422_2_spec.rb +0 -42
- data/spec/models/inline_response_422_3_spec.rb +0 -42
- data/spec/models/inline_response_422_4_spec.rb +0 -42
- data/spec/models/inline_response_422_5_spec.rb +0 -42
- data/spec/models/inline_response_422_6_spec.rb +0 -42
- data/spec/models/inline_response_422_7_meta_spec.rb +0 -42
- data/spec/models/inline_response_422_7_spec.rb +0 -42
- data/spec/models/inline_response_422_8_meta_spec.rb +0 -42
- data/spec/models/inline_response_422_8_object_spec.rb +0 -42
- data/spec/models/inline_response_422_8_spec.rb +0 -48
- data/spec/models/inline_response_422_9_spec.rb +0 -42
- data/spec/models/inline_response_422_meta_spec.rb +0 -42
- data/spec/models/inline_response_422_object_spec.rb +0 -42
- data/spec/models/inline_response_422_spec.rb +0 -48
- data/spec/models/invalid_debit_spec.rb +0 -78
- data/spec/models/invalid_document_spec.rb +0 -100
- data/spec/models/invalid_recipient_spec.rb +0 -66
- data/spec/models/invalid_sender_spec.rb +0 -148
- data/spec/models/invalid_webhook_spec.rb +0 -60
- data/spec/models/meta_2_pagination_spec.rb +0 -66
- data/spec/models/meta_2_spec.rb +0 -42
- data/spec/models/meta_pagination_spec.rb +0 -66
- data/spec/models/meta_spec.rb +0 -42
- data/spec/models/object_spec.rb +0 -48
- data/spec/models/opposite_payment_method_base_spec.rb +0 -72
- data/spec/models/opposite_payment_method_spec.rb +0 -72
- data/spec/models/pagination_pagination_spec.rb +0 -66
- data/spec/models/payin_method_base_spec.rb +0 -66
- data/spec/models/payin_method_details_base_spec.rb +0 -36
- data/spec/models/payin_method_type_base_spec.rb +0 -42
- data/spec/models/payin_method_type_spec.rb +0 -42
- data/spec/models/payment_method_base_spec.rb +0 -66
- data/spec/models/payout_method_base_spec.rb +0 -54
- data/spec/models/payout_method_details_base_spec.rb +0 -36
- data/spec/models/payout_method_error_response_spec.rb +0 -60
- data/spec/models/payout_method_valid_response_spec.rb +0 -60
- data/spec/models/recipient_base_spec.rb +0 -54
- data/spec/models/recipient_error_response_spec.rb +0 -60
- data/spec/models/recipient_valid_response_spec.rb +0 -60
- data/spec/models/sender_base_spec.rb +0 -136
- data/spec/models/sender_error_response_spec.rb +0 -142
- data/spec/models/sender_existing_request_spec.rb +0 -42
- data/spec/models/sender_full_request_spec.rb +0 -136
- data/spec/models/sender_valid_response_spec.rb +0 -142
- data/spec/models/transaction_base_spec.rb +0 -60
- data/spec/models/transaction_error_response_spec.rb +0 -66
- data/spec/models/transaction_request_base_spec.rb +0 -48
- data/spec/models/transaction_request_error_response_spec.rb +0 -54
- data/spec/models/transaction_request_request_spec.rb +0 -48
- data/spec/models/transaction_request_valid_response_spec.rb +0 -54
- data/spec/models/transaction_valid_response_spec.rb +0 -66
- data/spec/models/valid_debit_spec.rb +0 -90
- data/spec/models/webhook_base_spec.rb +0 -54
- data/spec/models/webhook_definition_base_spec.rb +0 -54
- data/spec/models/webhook_definition_error_response_spec.rb +0 -60
- data/spec/models/webhook_definition_valid_response_spec.rb +0 -60
- data/spec/models/webhook_error_response_spec.rb +0 -60
- data/spec/models/webhook_log_base_metadata_params_spec.rb +0 -42
- data/spec/models/webhook_log_base_metadata_request_spec.rb +0 -54
- data/spec/models/webhook_log_base_metadata_response_spec.rb +0 -54
- data/spec/models/webhook_log_base_metadata_spec.rb +0 -96
- data/spec/models/webhook_log_base_spec.rb +0 -72
- data/spec/models/webhook_log_metadata_params_spec.rb +0 -42
- data/spec/models/webhook_request_spec.rb +0 -54
- data/spec/models/webhook_valid_response_spec.rb +0 -60
@@ -1,25 +1,25 @@
|
|
1
1
|
=begin
|
2
2
|
#BitPesa API
|
3
3
|
|
4
|
-
#
|
4
|
+
#Reference documentation for the BitPesa API V1
|
5
5
|
|
6
6
|
OpenAPI spec version: 1.0
|
7
7
|
|
8
|
-
Generated by: https://
|
9
|
-
|
8
|
+
Generated by: https://openapi-generator.tech
|
9
|
+
OpenAPI Generator version: 4.0.0-beta2
|
10
10
|
|
11
11
|
=end
|
12
12
|
|
13
13
|
require 'spec_helper'
|
14
14
|
require 'json'
|
15
15
|
|
16
|
-
# Unit tests for
|
17
|
-
# Automatically generated by
|
16
|
+
# Unit tests for Bitpesa::WebhooksApi
|
17
|
+
# Automatically generated by openapi-generator (https://openapi-generator.tech)
|
18
18
|
# Please update as you see appropriate
|
19
19
|
describe 'WebhooksApi' do
|
20
20
|
before do
|
21
21
|
# run before each test
|
22
|
-
@instance =
|
22
|
+
@instance = Bitpesa::WebhooksApi.new
|
23
23
|
end
|
24
24
|
|
25
25
|
after do
|
@@ -28,7 +28,7 @@ describe 'WebhooksApi' do
|
|
28
28
|
|
29
29
|
describe 'test an instance of WebhooksApi' do
|
30
30
|
it 'should create an instance of WebhooksApi' do
|
31
|
-
expect(@instance).to be_instance_of(
|
31
|
+
expect(@instance).to be_instance_of(Bitpesa::WebhooksApi)
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
@@ -37,9 +37,9 @@ describe 'WebhooksApi' do
|
|
37
37
|
# Unsubscribes from a webhook specified
|
38
38
|
# @param webhook_id The ID of webhook to cancel. Example: `/v1/webhooks/9d4d7b73-a94c-4979-ab57-09074fd55d33`
|
39
39
|
# @param [Hash] opts the optional parameters
|
40
|
-
# @return [
|
40
|
+
# @return [WebhookDefinitionResponse]
|
41
41
|
describe 'delete_webhook test' do
|
42
|
-
it
|
42
|
+
it 'should work' do
|
43
43
|
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
|
44
44
|
end
|
45
45
|
end
|
@@ -49,9 +49,9 @@ describe 'WebhooksApi' do
|
|
49
49
|
# Look up a webhook's details with its ID
|
50
50
|
# @param webhook_id The ID of the Webhook to look up Example: `/v1/webhooks/9d4d7b73-a94c-4979-ab57-09074fd55d33`
|
51
51
|
# @param [Hash] opts the optional parameters
|
52
|
-
# @return [
|
52
|
+
# @return [WebhookDefinitionResponse]
|
53
53
|
describe 'get_webhook test' do
|
54
|
-
it
|
54
|
+
it 'should work' do
|
55
55
|
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
|
56
56
|
end
|
57
57
|
end
|
@@ -60,9 +60,9 @@ describe 'WebhooksApi' do
|
|
60
60
|
# Find possible webhook events
|
61
61
|
# Fetching possible webhook events
|
62
62
|
# @param [Hash] opts the optional parameters
|
63
|
-
# @return [
|
63
|
+
# @return [WebhookDefinitionEventListResponse]
|
64
64
|
describe 'get_webhook_events test' do
|
65
|
-
it
|
65
|
+
it 'should work' do
|
66
66
|
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
|
67
67
|
end
|
68
68
|
end
|
@@ -70,12 +70,12 @@ describe 'WebhooksApi' do
|
|
70
70
|
# unit tests for get_webhooks
|
71
71
|
# Listing webhooks
|
72
72
|
# Get a list of created webhooks
|
73
|
-
# @param page The page number to request
|
74
|
-
# @param per The number of results to load per page
|
75
73
|
# @param [Hash] opts the optional parameters
|
76
|
-
# @
|
74
|
+
# @option opts [Integer] :page The page number to request (defaults to 1)
|
75
|
+
# @option opts [Integer] :per The number of results to load per page (defaults to 10)
|
76
|
+
# @return [WebhookDefinitionListResponse]
|
77
77
|
describe 'get_webhooks test' do
|
78
|
-
it
|
78
|
+
it 'should work' do
|
79
79
|
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
|
80
80
|
end
|
81
81
|
end
|
@@ -83,11 +83,11 @@ describe 'WebhooksApi' do
|
|
83
83
|
# unit tests for post_webhooks
|
84
84
|
# Creating a webhook
|
85
85
|
# Creates a new webhook, subscribing the provided endpoint to the specified event(s)
|
86
|
-
# @param
|
86
|
+
# @param webhook_definition_request
|
87
87
|
# @param [Hash] opts the optional parameters
|
88
|
-
# @return [
|
88
|
+
# @return [WebhookDefinitionResponse]
|
89
89
|
describe 'post_webhooks test' do
|
90
|
-
it
|
90
|
+
it 'should work' do
|
91
91
|
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
|
92
92
|
end
|
93
93
|
end
|
data/spec/api_client_spec.rb
CHANGED
@@ -1,169 +1,131 @@
|
|
1
1
|
=begin
|
2
2
|
#BitPesa API
|
3
3
|
|
4
|
-
#
|
4
|
+
#Reference documentation for the BitPesa API V1
|
5
5
|
|
6
6
|
OpenAPI spec version: 1.0
|
7
7
|
|
8
|
-
Generated by: https://
|
9
|
-
|
8
|
+
Generated by: https://openapi-generator.tech
|
9
|
+
OpenAPI Generator version: 4.0.0-beta2
|
10
10
|
|
11
11
|
=end
|
12
12
|
|
13
13
|
require 'spec_helper'
|
14
14
|
|
15
|
-
describe
|
15
|
+
describe Bitpesa::ApiClient do
|
16
16
|
context 'initialization' do
|
17
17
|
context 'URL stuff' do
|
18
18
|
context 'host' do
|
19
19
|
it 'removes http from host' do
|
20
|
-
|
21
|
-
expect(
|
20
|
+
Bitpesa.configure { |c| c.host = 'http://example.com' }
|
21
|
+
expect(Bitpesa::Configuration.default.host).to eq('example.com')
|
22
22
|
end
|
23
23
|
|
24
24
|
it 'removes https from host' do
|
25
|
-
|
26
|
-
expect(
|
25
|
+
Bitpesa.configure { |c| c.host = 'https://wookiee.com' }
|
26
|
+
expect(Bitpesa::ApiClient.default.config.host).to eq('wookiee.com')
|
27
27
|
end
|
28
28
|
|
29
29
|
it 'removes trailing path from host' do
|
30
|
-
|
31
|
-
expect(
|
30
|
+
Bitpesa.configure { |c| c.host = 'hobo.com/v4' }
|
31
|
+
expect(Bitpesa::Configuration.default.host).to eq('hobo.com')
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
35
35
|
context 'base_path' do
|
36
36
|
it "prepends a slash to base_path" do
|
37
|
-
|
38
|
-
expect(
|
37
|
+
Bitpesa.configure { |c| c.base_path = 'v4/dog' }
|
38
|
+
expect(Bitpesa::Configuration.default.base_path).to eq('/v4/dog')
|
39
39
|
end
|
40
40
|
|
41
41
|
it "doesn't prepend a slash if one is already there" do
|
42
|
-
|
43
|
-
expect(
|
42
|
+
Bitpesa.configure { |c| c.base_path = '/v4/dog' }
|
43
|
+
expect(Bitpesa::Configuration.default.base_path).to eq('/v4/dog')
|
44
44
|
end
|
45
45
|
|
46
46
|
it "ends up as a blank string if nil" do
|
47
|
-
|
48
|
-
expect(
|
47
|
+
Bitpesa.configure { |c| c.base_path = nil }
|
48
|
+
expect(Bitpesa::Configuration.default.base_path).to eq('')
|
49
49
|
end
|
50
50
|
end
|
51
51
|
end
|
52
52
|
end
|
53
53
|
|
54
|
-
describe
|
55
|
-
let(:config) { BitPesa::Configuration.new }
|
56
|
-
let(:api_client) { BitPesa::ApiClient.new(config) }
|
57
|
-
|
58
|
-
it "defaults to nil" do
|
59
|
-
expect(BitPesa::Configuration.default.params_encoding).to eq(nil)
|
60
|
-
expect(config.params_encoding).to eq(nil)
|
61
|
-
|
62
|
-
request = api_client.build_request(:get, '/test')
|
63
|
-
expect(request.options[:params_encoding]).to eq(nil)
|
64
|
-
end
|
65
|
-
|
66
|
-
it "can be customized" do
|
67
|
-
config.params_encoding = :multi
|
68
|
-
request = api_client.build_request(:get, '/test')
|
69
|
-
expect(request.options[:params_encoding]).to eq(:multi)
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
|
-
describe "timeout in #build_request" do
|
74
|
-
let(:config) { BitPesa::Configuration.new }
|
75
|
-
let(:api_client) { BitPesa::ApiClient.new(config) }
|
76
|
-
|
77
|
-
it "defaults to 0" do
|
78
|
-
expect(BitPesa::Configuration.default.timeout).to eq(0)
|
79
|
-
expect(config.timeout).to eq(0)
|
80
|
-
|
81
|
-
request = api_client.build_request(:get, '/test')
|
82
|
-
expect(request.options[:timeout]).to eq(0)
|
83
|
-
end
|
84
|
-
|
85
|
-
it "can be customized" do
|
86
|
-
config.timeout = 100
|
87
|
-
request = api_client.build_request(:get, '/test')
|
88
|
-
expect(request.options[:timeout]).to eq(100)
|
89
|
-
end
|
90
|
-
end
|
91
|
-
|
92
|
-
describe "#deserialize" do
|
54
|
+
describe '#deserialize' do
|
93
55
|
it "handles Array<Integer>" do
|
94
|
-
api_client =
|
95
|
-
headers = {'Content-Type' => 'application/json'}
|
56
|
+
api_client = Bitpesa::ApiClient.new
|
57
|
+
headers = { 'Content-Type' => 'application/json' }
|
96
58
|
response = double('response', headers: headers, body: '[12, 34]')
|
97
59
|
data = api_client.deserialize(response, 'Array<Integer>')
|
98
60
|
expect(data).to be_instance_of(Array)
|
99
61
|
expect(data).to eq([12, 34])
|
100
62
|
end
|
101
63
|
|
102
|
-
it
|
103
|
-
api_client =
|
104
|
-
headers = {'Content-Type' => 'application/json'}
|
64
|
+
it 'handles Array<Array<Integer>>' do
|
65
|
+
api_client = Bitpesa::ApiClient.new
|
66
|
+
headers = { 'Content-Type' => 'application/json' }
|
105
67
|
response = double('response', headers: headers, body: '[[12, 34], [56]]')
|
106
68
|
data = api_client.deserialize(response, 'Array<Array<Integer>>')
|
107
69
|
expect(data).to be_instance_of(Array)
|
108
70
|
expect(data).to eq([[12, 34], [56]])
|
109
71
|
end
|
110
72
|
|
111
|
-
it
|
112
|
-
api_client =
|
113
|
-
headers = {'Content-Type' => 'application/json'}
|
73
|
+
it 'handles Hash<String, String>' do
|
74
|
+
api_client = Bitpesa::ApiClient.new
|
75
|
+
headers = { 'Content-Type' => 'application/json' }
|
114
76
|
response = double('response', headers: headers, body: '{"message": "Hello"}')
|
115
77
|
data = api_client.deserialize(response, 'Hash<String, String>')
|
116
78
|
expect(data).to be_instance_of(Hash)
|
117
|
-
expect(data).to eq(
|
79
|
+
expect(data).to eq(:message => 'Hello')
|
118
80
|
end
|
119
81
|
end
|
120
82
|
|
121
83
|
describe "#object_to_hash" do
|
122
|
-
it
|
84
|
+
it 'ignores nils and includes empty arrays' do
|
123
85
|
# uncomment below to test object_to_hash for model
|
124
|
-
#api_client =
|
125
|
-
#_model =
|
86
|
+
# api_client = Bitpesa::ApiClient.new
|
87
|
+
# _model = Bitpesa::ModelName.new
|
126
88
|
# update the model attribute below
|
127
|
-
#_model.id = 1
|
89
|
+
# _model.id = 1
|
128
90
|
# update the expected value (hash) below
|
129
|
-
#expected = {id: 1, name: '', tags: []}
|
130
|
-
#expect(api_client.object_to_hash(_model)).to eq(expected)
|
91
|
+
# expected = {id: 1, name: '', tags: []}
|
92
|
+
# expect(api_client.object_to_hash(_model)).to eq(expected)
|
131
93
|
end
|
132
94
|
end
|
133
95
|
|
134
|
-
describe
|
96
|
+
describe '#build_collection_param' do
|
135
97
|
let(:param) { ['aa', 'bb', 'cc'] }
|
136
|
-
let(:api_client) {
|
98
|
+
let(:api_client) { Bitpesa::ApiClient.new }
|
137
99
|
|
138
|
-
it
|
100
|
+
it 'works for csv' do
|
139
101
|
expect(api_client.build_collection_param(param, :csv)).to eq('aa,bb,cc')
|
140
102
|
end
|
141
103
|
|
142
|
-
it
|
104
|
+
it 'works for ssv' do
|
143
105
|
expect(api_client.build_collection_param(param, :ssv)).to eq('aa bb cc')
|
144
106
|
end
|
145
107
|
|
146
|
-
it
|
108
|
+
it 'works for tsv' do
|
147
109
|
expect(api_client.build_collection_param(param, :tsv)).to eq("aa\tbb\tcc")
|
148
110
|
end
|
149
111
|
|
150
|
-
it
|
112
|
+
it 'works for pipes' do
|
151
113
|
expect(api_client.build_collection_param(param, :pipes)).to eq('aa|bb|cc')
|
152
114
|
end
|
153
115
|
|
154
|
-
it
|
116
|
+
it 'works for multi' do
|
155
117
|
expect(api_client.build_collection_param(param, :multi)).to eq(['aa', 'bb', 'cc'])
|
156
118
|
end
|
157
119
|
|
158
|
-
it
|
120
|
+
it 'fails for invalid collection format' do
|
159
121
|
expect(proc { api_client.build_collection_param(param, :INVALID) }).to raise_error(RuntimeError, 'unknown collection format: :INVALID')
|
160
122
|
end
|
161
123
|
end
|
162
124
|
|
163
|
-
describe
|
164
|
-
let(:api_client) {
|
125
|
+
describe '#json_mime?' do
|
126
|
+
let(:api_client) { Bitpesa::ApiClient.new }
|
165
127
|
|
166
|
-
it
|
128
|
+
it 'works' do
|
167
129
|
expect(api_client.json_mime?(nil)).to eq false
|
168
130
|
expect(api_client.json_mime?('')).to eq false
|
169
131
|
|
@@ -177,10 +139,10 @@ describe BitPesa::ApiClient do
|
|
177
139
|
end
|
178
140
|
end
|
179
141
|
|
180
|
-
describe
|
181
|
-
let(:api_client) {
|
142
|
+
describe '#select_header_accept' do
|
143
|
+
let(:api_client) { Bitpesa::ApiClient.new }
|
182
144
|
|
183
|
-
it
|
145
|
+
it 'works' do
|
184
146
|
expect(api_client.select_header_accept(nil)).to be_nil
|
185
147
|
expect(api_client.select_header_accept([])).to be_nil
|
186
148
|
|
@@ -193,10 +155,10 @@ describe BitPesa::ApiClient do
|
|
193
155
|
end
|
194
156
|
end
|
195
157
|
|
196
|
-
describe
|
197
|
-
let(:api_client) {
|
158
|
+
describe '#select_header_content_type' do
|
159
|
+
let(:api_client) { Bitpesa::ApiClient.new }
|
198
160
|
|
199
|
-
it
|
161
|
+
it 'works' do
|
200
162
|
expect(api_client.select_header_content_type(nil)).to eq('application/json')
|
201
163
|
expect(api_client.select_header_content_type([])).to eq('application/json')
|
202
164
|
|
@@ -208,10 +170,10 @@ describe BitPesa::ApiClient do
|
|
208
170
|
end
|
209
171
|
end
|
210
172
|
|
211
|
-
describe
|
212
|
-
let(:api_client) {
|
173
|
+
describe '#sanitize_filename' do
|
174
|
+
let(:api_client) { Bitpesa::ApiClient.new }
|
213
175
|
|
214
|
-
it
|
176
|
+
it 'works' do
|
215
177
|
expect(api_client.sanitize_filename('sun')).to eq('sun')
|
216
178
|
expect(api_client.sanitize_filename('sun.gif')).to eq('sun.gif')
|
217
179
|
expect(api_client.sanitize_filename('../sun.gif')).to eq('sun.gif')
|
data/spec/configuration_spec.rb
CHANGED
@@ -1,41 +1,41 @@
|
|
1
1
|
=begin
|
2
2
|
#BitPesa API
|
3
3
|
|
4
|
-
#
|
4
|
+
#Reference documentation for the BitPesa API V1
|
5
5
|
|
6
6
|
OpenAPI spec version: 1.0
|
7
7
|
|
8
|
-
Generated by: https://
|
9
|
-
|
8
|
+
Generated by: https://openapi-generator.tech
|
9
|
+
OpenAPI Generator version: 4.0.0-beta2
|
10
10
|
|
11
11
|
=end
|
12
12
|
|
13
13
|
require 'spec_helper'
|
14
14
|
|
15
|
-
describe
|
16
|
-
let(:config) {
|
15
|
+
describe Bitpesa::Configuration do
|
16
|
+
let(:config) { Bitpesa::Configuration.default }
|
17
17
|
|
18
18
|
before(:each) do
|
19
19
|
# uncomment below to setup host and base_path
|
20
|
-
#require 'URI'
|
21
|
-
#uri = URI.parse("https://api-
|
22
|
-
#
|
23
|
-
#
|
24
|
-
#
|
25
|
-
#end
|
20
|
+
# require 'URI'
|
21
|
+
# uri = URI.parse("https://api-sandbox.bitpesa.co/v1")
|
22
|
+
# Bitpesa.configure do |c|
|
23
|
+
# c.host = uri.host
|
24
|
+
# c.base_path = uri.path
|
25
|
+
# end
|
26
26
|
end
|
27
27
|
|
28
28
|
describe '#base_url' do
|
29
29
|
it 'should have the default value' do
|
30
30
|
# uncomment below to test default value of the base path
|
31
|
-
#expect(config.base_url).to eq("https://api-
|
31
|
+
# expect(config.base_url).to eq("https://api-sandbox.bitpesa.co/v1")
|
32
32
|
end
|
33
33
|
|
34
34
|
it 'should remove trailing slashes' do
|
35
35
|
[nil, '', '/', '//'].each do |base_path|
|
36
36
|
config.base_path = base_path
|
37
37
|
# uncomment below to test trailing slashes
|
38
|
-
#expect(config.base_url).to eq("https://api-
|
38
|
+
# expect(config.base_url).to eq("https://api-sandbox.bitpesa.co/v1")
|
39
39
|
end
|
40
40
|
end
|
41
41
|
end
|
@@ -1,12 +1,12 @@
|
|
1
1
|
=begin
|
2
2
|
#BitPesa API
|
3
3
|
|
4
|
-
#Reference documentation for the BitPesa API V1
|
4
|
+
#Reference documentation for the BitPesa API V1
|
5
5
|
|
6
6
|
OpenAPI spec version: 1.0
|
7
7
|
|
8
|
-
Generated by: https://
|
9
|
-
|
8
|
+
Generated by: https://openapi-generator.tech
|
9
|
+
OpenAPI Generator version: 4.0.0-beta2
|
10
10
|
|
11
11
|
=end
|
12
12
|
|
@@ -15,7 +15,7 @@ require 'json'
|
|
15
15
|
require 'date'
|
16
16
|
|
17
17
|
# Unit tests for Bitpesa::AccountMeta
|
18
|
-
# Automatically generated by
|
18
|
+
# Automatically generated by openapi-generator (https://openapi-generator.tech)
|
19
19
|
# Please update as you see appropriate
|
20
20
|
describe 'AccountMeta' do
|
21
21
|
before do
|
@@ -34,9 +34,8 @@ describe 'AccountMeta' do
|
|
34
34
|
end
|
35
35
|
describe 'test attribute "negative_balance"' do
|
36
36
|
it 'should work' do
|
37
|
-
|
37
|
+
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
|
38
38
|
end
|
39
39
|
end
|
40
40
|
|
41
41
|
end
|
42
|
-
|