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.
Files changed (240) hide show
  1. checksums.yaml +5 -5
  2. data/Gemfile +1 -0
  3. data/Gemfile.lock +5 -4
  4. data/README.md +19 -7
  5. data/docs/Sender.md +1 -0
  6. data/docs/SenderResponse.md +1 -0
  7. data/docs/SenderResponseExisting.md +8 -0
  8. data/docs/SenderResponseMeta.md +8 -0
  9. data/docs/SendersApi.md +2 -0
  10. data/docs/Transaction.md +1 -0
  11. data/docs/TransactionResponse.md +1 -0
  12. data/docs/TransactionResponseExisting.md +9 -0
  13. data/docs/TransactionResponseMeta.md +8 -0
  14. data/docs/TransactionsApi.md +2 -0
  15. data/example/client.rb +47 -9
  16. data/lib/bitpesa-sdk.rb +4 -0
  17. data/lib/bitpesa-sdk/api/senders_api.rb +3 -0
  18. data/lib/bitpesa-sdk/api/transactions_api.rb +3 -0
  19. data/lib/bitpesa-sdk/api_client.rb +1 -1
  20. data/lib/bitpesa-sdk/models/sender.rb +12 -2
  21. data/lib/bitpesa-sdk/models/sender_response.rb +13 -4
  22. data/lib/bitpesa-sdk/models/sender_response_existing.rb +195 -0
  23. data/lib/bitpesa-sdk/models/sender_response_meta.rb +195 -0
  24. data/lib/bitpesa-sdk/models/transaction.rb +11 -1
  25. data/lib/bitpesa-sdk/models/transaction_response.rb +13 -4
  26. data/lib/bitpesa-sdk/models/transaction_response_existing.rb +204 -0
  27. data/lib/bitpesa-sdk/models/transaction_response_meta.rb +195 -0
  28. data/lib/bitpesa-sdk/version.rb +1 -1
  29. data/spec/api/account_debits_api_spec.rb +17 -15
  30. data/spec/api/account_validation_api_spec.rb +10 -10
  31. data/spec/api/accounts_api_spec.rb +13 -13
  32. data/spec/api/api_logs_api_spec.rb +15 -11
  33. data/spec/api/currency_info_api_spec.rb +13 -13
  34. data/spec/api/documents_api_spec.rb +16 -14
  35. data/spec/api/logs_api_spec.rb +15 -11
  36. data/spec/api/payment_methods_api_spec.rb +11 -11
  37. data/spec/api/payout_methods_api_spec.rb +55 -11
  38. data/spec/api/recipients_api_spec.rb +23 -18
  39. data/spec/api/senders_api_spec.rb +26 -21
  40. data/spec/api/transactions_api_spec.rb +48 -22
  41. data/spec/api/webhooks_api_spec.rb +20 -20
  42. data/spec/api_client_spec.rb +52 -90
  43. data/spec/configuration_spec.rb +13 -13
  44. data/spec/models/account_meta_spec.rb +5 -6
  45. data/spec/models/api_log_spec.rb +16 -17
  46. data/spec/models/currency_spec.rb +27 -16
  47. data/spec/models/debit_request_spec.rb +9 -34
  48. data/spec/models/debit_spec.rb +42 -13
  49. data/spec/models/document_request_spec.rb +9 -56
  50. data/spec/models/document_spec.rb +71 -8
  51. data/spec/models/pagination_spec.rb +33 -10
  52. data/spec/models/payin_method_details_mobile_spec.rb +6 -7
  53. data/spec/models/payin_method_details_ngn_bank_spec.rb +5 -6
  54. data/spec/models/payment_method_spec.rb +19 -14
  55. data/spec/models/payout_method_details_balance_spec.rb +5 -6
  56. data/spec/models/payout_method_details_ghs_bank_spec.rb +8 -9
  57. data/spec/models/payout_method_details_iban_spec.rb +9 -10
  58. data/spec/models/payout_method_details_mad_cash_spec.rb +15 -24
  59. data/spec/models/payout_method_details_mobile_spec.rb +7 -8
  60. data/spec/models/payout_method_details_ngn_bank_spec.rb +9 -14
  61. data/spec/models/payout_method_details_xof_mobile_spec.rb +8 -13
  62. data/spec/models/payout_method_request_spec.rb +6 -19
  63. data/spec/models/payout_method_response_spec.rb +6 -19
  64. data/spec/models/payout_method_spec.rb +18 -19
  65. data/spec/models/recipient_request_spec.rb +6 -25
  66. data/spec/models/recipient_response_spec.rb +6 -103
  67. data/spec/models/recipient_spec.rb +127 -8
  68. data/spec/models/sender_request_spec.rb +9 -104
  69. data/spec/models/sender_response_existing_spec.rb +41 -0
  70. data/spec/models/sender_response_meta_spec.rb +41 -0
  71. data/spec/models/sender_response_spec.rb +8 -103
  72. data/spec/models/sender_spec.rb +167 -8
  73. data/spec/models/transaction_request_spec.rb +9 -16
  74. data/spec/models/transaction_response_existing_spec.rb +47 -0
  75. data/spec/models/transaction_response_meta_spec.rb +41 -0
  76. data/spec/models/transaction_response_spec.rb +8 -75
  77. data/spec/models/transaction_spec.rb +84 -13
  78. data/spec/models/transaction_traits_spec.rb +6 -7
  79. data/spec/models/webhook_definition_request_spec.rb +6 -19
  80. data/spec/models/webhook_log_metadata_request_spec.rb +10 -11
  81. data/spec/models/webhook_log_metadata_response_spec.rb +10 -11
  82. data/spec/models/webhook_log_metadata_spec.rb +17 -18
  83. data/spec/models/webhook_log_spec.rb +13 -14
  84. data/spec/models/webhook_spec.rb +7 -8
  85. data/spec/spec_helper.rb +4 -4
  86. metadata +19 -309
  87. data/example/.LICENSE.un~ +0 -0
  88. data/example/.client.rb.un~ +0 -0
  89. data/spec/api/transaction_requests_api_spec.rb +0 -76
  90. data/spec/models/account_base_spec.rb +0 -48
  91. data/spec/models/api_log_base_spec.rb +0 -90
  92. data/spec/models/body_spec.rb +0 -58
  93. data/spec/models/currency_base_spec.rb +0 -84
  94. data/spec/models/debit_base_spec.rb +0 -66
  95. data/spec/models/debit_error_response_spec.rb +0 -72
  96. data/spec/models/debit_valid_response_spec.rb +0 -72
  97. data/spec/models/default_document_spec.rb +0 -94
  98. data/spec/models/default_recipient_spec.rb +0 -60
  99. data/spec/models/default_sender_spec.rb +0 -142
  100. data/spec/models/default_webhook_spec.rb +0 -60
  101. data/spec/models/document_base_spec.rb +0 -88
  102. data/spec/models/document_error_response_spec.rb +0 -94
  103. data/spec/models/document_valid_response_spec.rb +0 -94
  104. data/spec/models/full_invalid_transaction_request_spec.rb +0 -78
  105. data/spec/models/full_invalid_transaction_spec.rb +0 -66
  106. data/spec/models/full_valid_transaction_request_spec.rb +0 -66
  107. data/spec/models/full_valid_transaction_spec.rb +0 -60
  108. data/spec/models/inline_response_200_10_spec.rb +0 -42
  109. data/spec/models/inline_response_200_11_spec.rb +0 -48
  110. data/spec/models/inline_response_200_12_spec.rb +0 -42
  111. data/spec/models/inline_response_200_13_spec.rb +0 -48
  112. data/spec/models/inline_response_200_14_spec.rb +0 -42
  113. data/spec/models/inline_response_200_15_spec.rb +0 -48
  114. data/spec/models/inline_response_200_16_spec.rb +0 -48
  115. data/spec/models/inline_response_200_17_spec.rb +0 -48
  116. data/spec/models/inline_response_200_18_spec.rb +0 -42
  117. data/spec/models/inline_response_200_19_spec.rb +0 -48
  118. data/spec/models/inline_response_200_1_spec.rb +0 -48
  119. data/spec/models/inline_response_200_20_spec.rb +0 -42
  120. data/spec/models/inline_response_200_21_object_spec.rb +0 -42
  121. data/spec/models/inline_response_200_21_spec.rb +0 -42
  122. data/spec/models/inline_response_200_22_object_spec.rb +0 -42
  123. data/spec/models/inline_response_200_22_spec.rb +0 -42
  124. data/spec/models/inline_response_200_23_object_spec.rb +0 -42
  125. data/spec/models/inline_response_200_23_spec.rb +0 -48
  126. data/spec/models/inline_response_200_24_spec.rb +0 -42
  127. data/spec/models/inline_response_200_25_spec.rb +0 -42
  128. data/spec/models/inline_response_200_26_spec.rb +0 -42
  129. data/spec/models/inline_response_200_27_spec.rb +0 -48
  130. data/spec/models/inline_response_200_28_spec.rb +0 -42
  131. data/spec/models/inline_response_200_29_spec.rb +0 -48
  132. data/spec/models/inline_response_200_2_object_spec.rb +0 -42
  133. data/spec/models/inline_response_200_2_spec.rb +0 -42
  134. data/spec/models/inline_response_200_30_spec.rb +0 -42
  135. data/spec/models/inline_response_200_31_spec.rb +0 -48
  136. data/spec/models/inline_response_200_32_spec.rb +0 -42
  137. data/spec/models/inline_response_200_33_spec.rb +0 -48
  138. data/spec/models/inline_response_200_34_spec.rb +0 -42
  139. data/spec/models/inline_response_200_35_spec.rb +0 -48
  140. data/spec/models/inline_response_200_36_spec.rb +0 -48
  141. data/spec/models/inline_response_200_37_spec.rb +0 -48
  142. data/spec/models/inline_response_200_38_spec.rb +0 -42
  143. data/spec/models/inline_response_200_39_spec.rb +0 -48
  144. data/spec/models/inline_response_200_3_spec.rb +0 -48
  145. data/spec/models/inline_response_200_40_spec.rb +0 -42
  146. data/spec/models/inline_response_200_4_object_spec.rb +0 -42
  147. data/spec/models/inline_response_200_4_spec.rb +0 -42
  148. data/spec/models/inline_response_200_5_spec.rb +0 -42
  149. data/spec/models/inline_response_200_6_spec.rb +0 -42
  150. data/spec/models/inline_response_200_7_spec.rb +0 -48
  151. data/spec/models/inline_response_200_8_spec.rb +0 -42
  152. data/spec/models/inline_response_200_9_spec.rb +0 -48
  153. data/spec/models/inline_response_200_spec.rb +0 -48
  154. data/spec/models/inline_response_201_10_spec.rb +0 -42
  155. data/spec/models/inline_response_201_11_spec.rb +0 -42
  156. data/spec/models/inline_response_201_1_spec.rb +0 -42
  157. data/spec/models/inline_response_201_2_spec.rb +0 -42
  158. data/spec/models/inline_response_201_3_spec.rb +0 -42
  159. data/spec/models/inline_response_201_4_spec.rb +0 -42
  160. data/spec/models/inline_response_201_5_spec.rb +0 -42
  161. data/spec/models/inline_response_201_6_spec.rb +0 -42
  162. data/spec/models/inline_response_201_7_spec.rb +0 -42
  163. data/spec/models/inline_response_201_8_spec.rb +0 -42
  164. data/spec/models/inline_response_201_9_spec.rb +0 -42
  165. data/spec/models/inline_response_201_spec.rb +0 -42
  166. data/spec/models/inline_response_400_1_spec.rb +0 -48
  167. data/spec/models/inline_response_400_spec.rb +0 -48
  168. data/spec/models/inline_response_422_10_spec.rb +0 -42
  169. data/spec/models/inline_response_422_11_spec.rb +0 -42
  170. data/spec/models/inline_response_422_12_spec.rb +0 -42
  171. data/spec/models/inline_response_422_13_spec.rb +0 -42
  172. data/spec/models/inline_response_422_14_spec.rb +0 -42
  173. data/spec/models/inline_response_422_1_meta_spec.rb +0 -42
  174. data/spec/models/inline_response_422_1_object_spec.rb +0 -42
  175. data/spec/models/inline_response_422_1_spec.rb +0 -42
  176. data/spec/models/inline_response_422_2_spec.rb +0 -42
  177. data/spec/models/inline_response_422_3_spec.rb +0 -42
  178. data/spec/models/inline_response_422_4_spec.rb +0 -42
  179. data/spec/models/inline_response_422_5_spec.rb +0 -42
  180. data/spec/models/inline_response_422_6_spec.rb +0 -42
  181. data/spec/models/inline_response_422_7_meta_spec.rb +0 -42
  182. data/spec/models/inline_response_422_7_spec.rb +0 -42
  183. data/spec/models/inline_response_422_8_meta_spec.rb +0 -42
  184. data/spec/models/inline_response_422_8_object_spec.rb +0 -42
  185. data/spec/models/inline_response_422_8_spec.rb +0 -48
  186. data/spec/models/inline_response_422_9_spec.rb +0 -42
  187. data/spec/models/inline_response_422_meta_spec.rb +0 -42
  188. data/spec/models/inline_response_422_object_spec.rb +0 -42
  189. data/spec/models/inline_response_422_spec.rb +0 -48
  190. data/spec/models/invalid_debit_spec.rb +0 -78
  191. data/spec/models/invalid_document_spec.rb +0 -100
  192. data/spec/models/invalid_recipient_spec.rb +0 -66
  193. data/spec/models/invalid_sender_spec.rb +0 -148
  194. data/spec/models/invalid_webhook_spec.rb +0 -60
  195. data/spec/models/meta_2_pagination_spec.rb +0 -66
  196. data/spec/models/meta_2_spec.rb +0 -42
  197. data/spec/models/meta_pagination_spec.rb +0 -66
  198. data/spec/models/meta_spec.rb +0 -42
  199. data/spec/models/object_spec.rb +0 -48
  200. data/spec/models/opposite_payment_method_base_spec.rb +0 -72
  201. data/spec/models/opposite_payment_method_spec.rb +0 -72
  202. data/spec/models/pagination_pagination_spec.rb +0 -66
  203. data/spec/models/payin_method_base_spec.rb +0 -66
  204. data/spec/models/payin_method_details_base_spec.rb +0 -36
  205. data/spec/models/payin_method_type_base_spec.rb +0 -42
  206. data/spec/models/payin_method_type_spec.rb +0 -42
  207. data/spec/models/payment_method_base_spec.rb +0 -66
  208. data/spec/models/payout_method_base_spec.rb +0 -54
  209. data/spec/models/payout_method_details_base_spec.rb +0 -36
  210. data/spec/models/payout_method_error_response_spec.rb +0 -60
  211. data/spec/models/payout_method_valid_response_spec.rb +0 -60
  212. data/spec/models/recipient_base_spec.rb +0 -54
  213. data/spec/models/recipient_error_response_spec.rb +0 -60
  214. data/spec/models/recipient_valid_response_spec.rb +0 -60
  215. data/spec/models/sender_base_spec.rb +0 -136
  216. data/spec/models/sender_error_response_spec.rb +0 -142
  217. data/spec/models/sender_existing_request_spec.rb +0 -42
  218. data/spec/models/sender_full_request_spec.rb +0 -136
  219. data/spec/models/sender_valid_response_spec.rb +0 -142
  220. data/spec/models/transaction_base_spec.rb +0 -60
  221. data/spec/models/transaction_error_response_spec.rb +0 -66
  222. data/spec/models/transaction_request_base_spec.rb +0 -48
  223. data/spec/models/transaction_request_error_response_spec.rb +0 -54
  224. data/spec/models/transaction_request_request_spec.rb +0 -48
  225. data/spec/models/transaction_request_valid_response_spec.rb +0 -54
  226. data/spec/models/transaction_valid_response_spec.rb +0 -66
  227. data/spec/models/valid_debit_spec.rb +0 -90
  228. data/spec/models/webhook_base_spec.rb +0 -54
  229. data/spec/models/webhook_definition_base_spec.rb +0 -54
  230. data/spec/models/webhook_definition_error_response_spec.rb +0 -60
  231. data/spec/models/webhook_definition_valid_response_spec.rb +0 -60
  232. data/spec/models/webhook_error_response_spec.rb +0 -60
  233. data/spec/models/webhook_log_base_metadata_params_spec.rb +0 -42
  234. data/spec/models/webhook_log_base_metadata_request_spec.rb +0 -54
  235. data/spec/models/webhook_log_base_metadata_response_spec.rb +0 -54
  236. data/spec/models/webhook_log_base_metadata_spec.rb +0 -96
  237. data/spec/models/webhook_log_base_spec.rb +0 -72
  238. data/spec/models/webhook_log_metadata_params_spec.rb +0 -42
  239. data/spec/models/webhook_request_spec.rb +0 -54
  240. data/spec/models/webhook_valid_response_spec.rb +0 -60
@@ -16,17 +16,21 @@ module Bitpesa
16
16
  class SenderResponse
17
17
  attr_accessor :object
18
18
 
19
+ attr_accessor :meta
20
+
19
21
  # Attribute mapping from ruby-style variable name to JSON key.
20
22
  def self.attribute_map
21
23
  {
22
- :'object' => :'object'
24
+ :'object' => :'object',
25
+ :'meta' => :'meta'
23
26
  }
24
27
  end
25
28
 
26
29
  # Attribute type mapping.
27
30
  def self.openapi_types
28
31
  {
29
- :'object' => :'Sender'
32
+ :'object' => :'Sender',
33
+ :'meta' => :'SenderResponseMeta'
30
34
  }
31
35
  end
32
36
 
@@ -41,6 +45,10 @@ module Bitpesa
41
45
  if attributes.has_key?(:'object')
42
46
  self.object = attributes[:'object']
43
47
  end
48
+
49
+ if attributes.has_key?(:'meta')
50
+ self.meta = attributes[:'meta']
51
+ end
44
52
  end
45
53
 
46
54
  # Show invalid properties with the reasons. Usually used together with valid?
@@ -61,7 +69,8 @@ module Bitpesa
61
69
  def ==(o)
62
70
  return true if self.equal?(o)
63
71
  self.class == o.class &&
64
- object == o.object
72
+ object == o.object &&
73
+ meta == o.meta
65
74
  end
66
75
 
67
76
  # @see the `==` method
@@ -73,7 +82,7 @@ module Bitpesa
73
82
  # Calculates hash code according to all attributes.
74
83
  # @return [Fixnum] Hash code
75
84
  def hash
76
- [object].hash
85
+ [object, meta].hash
77
86
  end
78
87
 
79
88
  require 'active_support/core_ext/hash'
@@ -0,0 +1,195 @@
1
+ =begin
2
+ #BitPesa API
3
+
4
+ #Reference documentation for the BitPesa API V1
5
+
6
+ OpenAPI spec version: 1.0
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 4.0.0-beta2
10
+
11
+ =end
12
+
13
+ require 'date'
14
+
15
+ module Bitpesa
16
+ class SenderResponseExisting
17
+ attr_accessor :sender
18
+
19
+ # Attribute mapping from ruby-style variable name to JSON key.
20
+ def self.attribute_map
21
+ {
22
+ :'sender' => :'sender'
23
+ }
24
+ end
25
+
26
+ # Attribute type mapping.
27
+ def self.openapi_types
28
+ {
29
+ :'sender' => :'Sender'
30
+ }
31
+ end
32
+
33
+ # Initializes the object
34
+ # @param [Hash] attributes Model attributes in the form of hash
35
+ def initialize(attributes = {})
36
+ return unless attributes.is_a?(Hash)
37
+
38
+ # convert string to symbol for hash key
39
+ attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
40
+
41
+ if attributes.has_key?(:'sender')
42
+ self.sender = attributes[:'sender']
43
+ end
44
+ end
45
+
46
+ # Show invalid properties with the reasons. Usually used together with valid?
47
+ # @return Array for valid properties with the reasons
48
+ def list_invalid_properties
49
+ invalid_properties = Array.new
50
+ invalid_properties
51
+ end
52
+
53
+ # Check to see if the all the properties in the model are valid
54
+ # @return true if the model is valid
55
+ def valid?
56
+ true
57
+ end
58
+
59
+ # Checks equality by comparing each attribute.
60
+ # @param [Object] Object to be compared
61
+ def ==(o)
62
+ return true if self.equal?(o)
63
+ self.class == o.class &&
64
+ sender == o.sender
65
+ end
66
+
67
+ # @see the `==` method
68
+ # @param [Object] Object to be compared
69
+ def eql?(o)
70
+ self == o
71
+ end
72
+
73
+ # Calculates hash code according to all attributes.
74
+ # @return [Fixnum] Hash code
75
+ def hash
76
+ [sender].hash
77
+ end
78
+
79
+ require 'active_support/core_ext/hash'
80
+ require 'active_support/hash_with_indifferent_access.rb'
81
+ # Builds the object from hash
82
+ # @param [Hash] attributes Model attributes in the form of hash
83
+ # @return [Object] Returns the model itself
84
+ def build_from_hash(attributes)
85
+ return nil unless attributes.is_a?(Hash)
86
+ self.class.openapi_types.each_pair do |key, type|
87
+ if type =~ /\AArray<(.*)>/i
88
+ # check to ensure the input is an array given that the the attribute
89
+ # is documented as an array but the input is not
90
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
91
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
92
+ end
93
+ elsif !attributes[self.class.attribute_map[key]].nil?
94
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
95
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
96
+ end
97
+
98
+ self
99
+ end
100
+
101
+ # Deserializes the data based on type
102
+ # @param string type Data type
103
+ # @param string value Value to be deserialized
104
+ # @return [Object] Deserialized data
105
+ def _deserialize(type, value)
106
+ case type.to_sym
107
+ when :DateTime
108
+ DateTime.parse(value)
109
+ when :Date
110
+ Date.parse(value)
111
+ when :String
112
+ value.to_s
113
+ when :Integer
114
+ value.to_i
115
+ when :Float
116
+ value.to_f
117
+ when :BOOLEAN
118
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
119
+ true
120
+ else
121
+ false
122
+ end
123
+ when :Object
124
+ # generic object (usually a Hash), return directly
125
+ value
126
+ when /\AArray<(?<inner_type>.+)>\z/
127
+ inner_type = Regexp.last_match[:inner_type]
128
+ value.map { |v| _deserialize(inner_type, v) }
129
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
130
+ k_type = Regexp.last_match[:k_type]
131
+ v_type = Regexp.last_match[:v_type]
132
+ {}.tap do |hash|
133
+ value.each do |k, v|
134
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
135
+ end
136
+ end
137
+ else # model
138
+ temp_model = Bitpesa.const_get(type).new
139
+ temp_model.build_from_hash(value)
140
+ end
141
+ end
142
+
143
+ # Returns the string representation of the object
144
+ # @return [String] String presentation of the object
145
+ def to_s
146
+ to_hash.to_s
147
+ end
148
+
149
+ # to_body is an alias to to_hash (backward compatibility)
150
+ # @return [Hash] Returns the object in the form of hash
151
+ def to_body
152
+ to_hash
153
+ end
154
+
155
+ # Returns the object in the form of hash
156
+ # @return [Hash] Returns the object in the form of hash
157
+ def to_hash
158
+ hash = {}
159
+ self.class.attribute_map.each_pair do |attr, param|
160
+ value = self.send(attr)
161
+ next if value.nil?
162
+ hash[param] = _to_hash(value)
163
+ end
164
+ ::ActiveSupport::HashWithIndifferentAccess.new(hash)
165
+ end
166
+
167
+ def [](key)
168
+ to_hash[key]
169
+ end
170
+
171
+ def dig(*args)
172
+ to_hash.dig(*args)
173
+ end
174
+
175
+ # Outputs non-array value in the form of hash
176
+ # For object, use to_hash. Otherwise, just return the value
177
+ # @param [Object] value Any valid value
178
+ # @return [Hash] Returns the value in the form of hash
179
+ def _to_hash(value)
180
+ if value.is_a?(Array)
181
+ value.compact.map { |v| _to_hash(v) }
182
+ elsif value.is_a?(Hash)
183
+ {}.tap do |hash|
184
+ value.each { |k, v| hash[k] = _to_hash(v) }
185
+ end
186
+ elsif value.respond_to? :to_hash
187
+ value.to_hash
188
+ else
189
+ value
190
+ end
191
+ end
192
+
193
+ end
194
+
195
+ end
@@ -0,0 +1,195 @@
1
+ =begin
2
+ #BitPesa API
3
+
4
+ #Reference documentation for the BitPesa API V1
5
+
6
+ OpenAPI spec version: 1.0
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 4.0.0-beta2
10
+
11
+ =end
12
+
13
+ require 'date'
14
+
15
+ module Bitpesa
16
+ class SenderResponseMeta
17
+ attr_accessor :existing
18
+
19
+ # Attribute mapping from ruby-style variable name to JSON key.
20
+ def self.attribute_map
21
+ {
22
+ :'existing' => :'existing'
23
+ }
24
+ end
25
+
26
+ # Attribute type mapping.
27
+ def self.openapi_types
28
+ {
29
+ :'existing' => :'SenderResponseExisting'
30
+ }
31
+ end
32
+
33
+ # Initializes the object
34
+ # @param [Hash] attributes Model attributes in the form of hash
35
+ def initialize(attributes = {})
36
+ return unless attributes.is_a?(Hash)
37
+
38
+ # convert string to symbol for hash key
39
+ attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
40
+
41
+ if attributes.has_key?(:'existing')
42
+ self.existing = attributes[:'existing']
43
+ end
44
+ end
45
+
46
+ # Show invalid properties with the reasons. Usually used together with valid?
47
+ # @return Array for valid properties with the reasons
48
+ def list_invalid_properties
49
+ invalid_properties = Array.new
50
+ invalid_properties
51
+ end
52
+
53
+ # Check to see if the all the properties in the model are valid
54
+ # @return true if the model is valid
55
+ def valid?
56
+ true
57
+ end
58
+
59
+ # Checks equality by comparing each attribute.
60
+ # @param [Object] Object to be compared
61
+ def ==(o)
62
+ return true if self.equal?(o)
63
+ self.class == o.class &&
64
+ existing == o.existing
65
+ end
66
+
67
+ # @see the `==` method
68
+ # @param [Object] Object to be compared
69
+ def eql?(o)
70
+ self == o
71
+ end
72
+
73
+ # Calculates hash code according to all attributes.
74
+ # @return [Fixnum] Hash code
75
+ def hash
76
+ [existing].hash
77
+ end
78
+
79
+ require 'active_support/core_ext/hash'
80
+ require 'active_support/hash_with_indifferent_access.rb'
81
+ # Builds the object from hash
82
+ # @param [Hash] attributes Model attributes in the form of hash
83
+ # @return [Object] Returns the model itself
84
+ def build_from_hash(attributes)
85
+ return nil unless attributes.is_a?(Hash)
86
+ self.class.openapi_types.each_pair do |key, type|
87
+ if type =~ /\AArray<(.*)>/i
88
+ # check to ensure the input is an array given that the the attribute
89
+ # is documented as an array but the input is not
90
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
91
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
92
+ end
93
+ elsif !attributes[self.class.attribute_map[key]].nil?
94
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
95
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
96
+ end
97
+
98
+ self
99
+ end
100
+
101
+ # Deserializes the data based on type
102
+ # @param string type Data type
103
+ # @param string value Value to be deserialized
104
+ # @return [Object] Deserialized data
105
+ def _deserialize(type, value)
106
+ case type.to_sym
107
+ when :DateTime
108
+ DateTime.parse(value)
109
+ when :Date
110
+ Date.parse(value)
111
+ when :String
112
+ value.to_s
113
+ when :Integer
114
+ value.to_i
115
+ when :Float
116
+ value.to_f
117
+ when :BOOLEAN
118
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
119
+ true
120
+ else
121
+ false
122
+ end
123
+ when :Object
124
+ # generic object (usually a Hash), return directly
125
+ value
126
+ when /\AArray<(?<inner_type>.+)>\z/
127
+ inner_type = Regexp.last_match[:inner_type]
128
+ value.map { |v| _deserialize(inner_type, v) }
129
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
130
+ k_type = Regexp.last_match[:k_type]
131
+ v_type = Regexp.last_match[:v_type]
132
+ {}.tap do |hash|
133
+ value.each do |k, v|
134
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
135
+ end
136
+ end
137
+ else # model
138
+ temp_model = Bitpesa.const_get(type).new
139
+ temp_model.build_from_hash(value)
140
+ end
141
+ end
142
+
143
+ # Returns the string representation of the object
144
+ # @return [String] String presentation of the object
145
+ def to_s
146
+ to_hash.to_s
147
+ end
148
+
149
+ # to_body is an alias to to_hash (backward compatibility)
150
+ # @return [Hash] Returns the object in the form of hash
151
+ def to_body
152
+ to_hash
153
+ end
154
+
155
+ # Returns the object in the form of hash
156
+ # @return [Hash] Returns the object in the form of hash
157
+ def to_hash
158
+ hash = {}
159
+ self.class.attribute_map.each_pair do |attr, param|
160
+ value = self.send(attr)
161
+ next if value.nil?
162
+ hash[param] = _to_hash(value)
163
+ end
164
+ ::ActiveSupport::HashWithIndifferentAccess.new(hash)
165
+ end
166
+
167
+ def [](key)
168
+ to_hash[key]
169
+ end
170
+
171
+ def dig(*args)
172
+ to_hash.dig(*args)
173
+ end
174
+
175
+ # Outputs non-array value in the form of hash
176
+ # For object, use to_hash. Otherwise, just return the value
177
+ # @param [Object] value Any valid value
178
+ # @return [Hash] Returns the value in the form of hash
179
+ def _to_hash(value)
180
+ if value.is_a?(Array)
181
+ value.compact.map { |v| _to_hash(v) }
182
+ elsif value.is_a?(Hash)
183
+ {}.tap do |hash|
184
+ value.each { |k, v| hash[k] = _to_hash(v) }
185
+ end
186
+ elsif value.respond_to? :to_hash
187
+ value.to_hash
188
+ else
189
+ value
190
+ end
191
+ end
192
+
193
+ end
194
+
195
+ end
@@ -51,6 +51,9 @@ module Bitpesa
51
51
  # The latest time when the transaction has to be funded, otherwise it will be cancelled
52
52
  attr_accessor :expires_at
53
53
 
54
+ # Optional ID that is supplied by partner linking it to the partner's own Sender ID. Note: if present we will validate whether the sent ID is a duplicate in our system or not.
55
+ attr_accessor :external_id
56
+
54
57
  attr_accessor :id
55
58
 
56
59
  # The fields that have some problems and don't pass validation
@@ -72,6 +75,7 @@ module Bitpesa
72
75
  :'due_amount' => :'due_amount',
73
76
  :'created_at' => :'created_at',
74
77
  :'expires_at' => :'expires_at',
78
+ :'external_id' => :'external_id',
75
79
  :'id' => :'id',
76
80
  :'errors' => :'errors'
77
81
  }
@@ -93,6 +97,7 @@ module Bitpesa
93
97
  :'due_amount' => :'Float',
94
98
  :'created_at' => :'DateTime',
95
99
  :'expires_at' => :'DateTime',
100
+ :'external_id' => :'String',
96
101
  :'id' => :'String',
97
102
  :'errors' => :'Hash<String, Array<ValidationErrorDescription>>'
98
103
  }
@@ -162,6 +167,10 @@ module Bitpesa
162
167
  self.expires_at = attributes[:'expires_at']
163
168
  end
164
169
 
170
+ if attributes.has_key?(:'external_id')
171
+ self.external_id = attributes[:'external_id']
172
+ end
173
+
165
174
  if attributes.has_key?(:'id')
166
175
  self.id = attributes[:'id']
167
176
  end
@@ -219,6 +228,7 @@ module Bitpesa
219
228
  due_amount == o.due_amount &&
220
229
  created_at == o.created_at &&
221
230
  expires_at == o.expires_at &&
231
+ external_id == o.external_id &&
222
232
  id == o.id &&
223
233
  errors == o.errors
224
234
  end
@@ -232,7 +242,7 @@ module Bitpesa
232
242
  # Calculates hash code according to all attributes.
233
243
  # @return [Fixnum] Hash code
234
244
  def hash
235
- [input_currency, payin_methods, metadata, sender, recipients, traits, state, input_amount, payin_reference, paid_amount, due_amount, created_at, expires_at, id, errors].hash
245
+ [input_currency, payin_methods, metadata, sender, recipients, traits, state, input_amount, payin_reference, paid_amount, due_amount, created_at, expires_at, external_id, id, errors].hash
236
246
  end
237
247
 
238
248
  require 'active_support/core_ext/hash'