processout 4.0.0 → 6.0.0

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.
@@ -11,6 +11,8 @@ module ProcessOut
11
11
  attr_reader :request_origin
12
12
  attr_reader :id
13
13
  attr_reader :channel
14
+ attr_reader :threeds_sdk
15
+ attr_reader :platform
14
16
  attr_reader :ip_address
15
17
  attr_reader :user_agent
16
18
  attr_reader :header_accept
@@ -35,6 +37,14 @@ module ProcessOut
35
37
  @channel = val
36
38
  end
37
39
 
40
+ def threeds_sdk=(val)
41
+ @threeds_sdk = val
42
+ end
43
+
44
+ def platform=(val)
45
+ @platform = val
46
+ end
47
+
38
48
  def ip_address=(val)
39
49
  @ip_address = val
40
50
  end
@@ -86,6 +96,8 @@ module ProcessOut
86
96
  self.request_origin = data.fetch(:request_origin, nil)
87
97
  self.id = data.fetch(:id, nil)
88
98
  self.channel = data.fetch(:channel, nil)
99
+ self.threeds_sdk = data.fetch(:threeds_sdk, nil)
100
+ self.platform = data.fetch(:platform, nil)
89
101
  self.ip_address = data.fetch(:ip_address, nil)
90
102
  self.user_agent = data.fetch(:user_agent, nil)
91
103
  self.header_accept = data.fetch(:header_accept, nil)
@@ -110,6 +122,8 @@ module ProcessOut
110
122
  "request_origin": self.request_origin,
111
123
  "id": self.id,
112
124
  "channel": self.channel,
125
+ "threeds_sdk": self.threeds_sdk,
126
+ "platform": self.platform,
113
127
  "ip_address": self.ip_address,
114
128
  "user_agent": self.user_agent,
115
129
  "header_accept": self.header_accept,
@@ -139,6 +153,12 @@ module ProcessOut
139
153
  if data.include? "channel"
140
154
  self.channel = data["channel"]
141
155
  end
156
+ if data.include? "threeds_sdk"
157
+ self.threeds_sdk = data["threeds_sdk"]
158
+ end
159
+ if data.include? "platform"
160
+ self.platform = data["platform"]
161
+ end
142
162
  if data.include? "ip_address"
143
163
  self.ip_address = data["ip_address"]
144
164
  end
@@ -183,6 +203,8 @@ module ProcessOut
183
203
  self.request_origin = data.fetch(:request_origin, self.request_origin)
184
204
  self.id = data.fetch(:id, self.id)
185
205
  self.channel = data.fetch(:channel, self.channel)
206
+ self.threeds_sdk = data.fetch(:threeds_sdk, self.threeds_sdk)
207
+ self.platform = data.fetch(:platform, self.platform)
186
208
  self.ip_address = data.fetch(:ip_address, self.ip_address)
187
209
  self.user_agent = data.fetch(:user_agent, self.user_agent)
188
210
  self.header_accept = data.fetch(:header_accept, self.header_accept)
@@ -15,12 +15,11 @@ module ProcessOut
15
15
  attr_reader :transaction_id
16
16
  attr_reader :customer
17
17
  attr_reader :customer_id
18
- attr_reader :subscription
19
- attr_reader :subscription_id
20
18
  attr_reader :token
21
19
  attr_reader :token_id
22
20
  attr_reader :details
23
21
  attr_reader :submerchant
22
+ attr_reader :submerchant_id
24
23
  attr_reader :url
25
24
  attr_reader :url_qrcode
26
25
  attr_reader :name
@@ -60,6 +59,7 @@ module ProcessOut
60
59
  attr_reader :verification
61
60
  attr_reader :auto_capture_at
62
61
  attr_reader :reference_id
62
+ attr_reader :payment_processing_config
63
63
 
64
64
 
65
65
  def id=(val)
@@ -126,26 +126,6 @@ module ProcessOut
126
126
  @customer_id = val
127
127
  end
128
128
 
129
- def subscription=(val)
130
- if val.nil?
131
- @subscription = val
132
- return
133
- end
134
-
135
- if val.instance_of? Subscription
136
- @subscription = val
137
- else
138
- obj = Subscription.new(@client)
139
- obj.fill_with_data(val)
140
- @subscription = obj
141
- end
142
-
143
- end
144
-
145
- def subscription_id=(val)
146
- @subscription_id = val
147
- end
148
-
149
129
  def token=(val)
150
130
  if val.nil?
151
131
  @token = val
@@ -202,6 +182,10 @@ module ProcessOut
202
182
 
203
183
  end
204
184
 
185
+ def submerchant_id=(val)
186
+ @submerchant_id = val
187
+ end
188
+
205
189
  def url=(val)
206
190
  @url = val
207
191
  end
@@ -454,6 +438,22 @@ module ProcessOut
454
438
  @reference_id = val
455
439
  end
456
440
 
441
+ def payment_processing_config=(val)
442
+ if val.nil?
443
+ @payment_processing_config = val
444
+ return
445
+ end
446
+
447
+ if val.instance_of? PaymentProcessingConfiguration
448
+ @payment_processing_config = val
449
+ else
450
+ obj = PaymentProcessingConfiguration.new(@client)
451
+ obj.fill_with_data(val)
452
+ @payment_processing_config = obj
453
+ end
454
+
455
+ end
456
+
457
457
 
458
458
  # Initializes the Invoice object
459
459
  # Params:
@@ -469,12 +469,11 @@ module ProcessOut
469
469
  self.transaction_id = data.fetch(:transaction_id, nil)
470
470
  self.customer = data.fetch(:customer, nil)
471
471
  self.customer_id = data.fetch(:customer_id, nil)
472
- self.subscription = data.fetch(:subscription, nil)
473
- self.subscription_id = data.fetch(:subscription_id, nil)
474
472
  self.token = data.fetch(:token, nil)
475
473
  self.token_id = data.fetch(:token_id, nil)
476
474
  self.details = data.fetch(:details, nil)
477
475
  self.submerchant = data.fetch(:submerchant, nil)
476
+ self.submerchant_id = data.fetch(:submerchant_id, nil)
478
477
  self.url = data.fetch(:url, nil)
479
478
  self.url_qrcode = data.fetch(:url_qrcode, nil)
480
479
  self.name = data.fetch(:name, nil)
@@ -514,6 +513,7 @@ module ProcessOut
514
513
  self.verification = data.fetch(:verification, nil)
515
514
  self.auto_capture_at = data.fetch(:auto_capture_at, nil)
516
515
  self.reference_id = data.fetch(:reference_id, nil)
516
+ self.payment_processing_config = data.fetch(:payment_processing_config, nil)
517
517
 
518
518
  end
519
519
 
@@ -532,12 +532,11 @@ module ProcessOut
532
532
  "transaction_id": self.transaction_id,
533
533
  "customer": self.customer,
534
534
  "customer_id": self.customer_id,
535
- "subscription": self.subscription,
536
- "subscription_id": self.subscription_id,
537
535
  "token": self.token,
538
536
  "token_id": self.token_id,
539
537
  "details": self.details,
540
538
  "submerchant": self.submerchant,
539
+ "submerchant_id": self.submerchant_id,
541
540
  "url": self.url,
542
541
  "url_qrcode": self.url_qrcode,
543
542
  "name": self.name,
@@ -577,6 +576,7 @@ module ProcessOut
577
576
  "verification": self.verification,
578
577
  "auto_capture_at": self.auto_capture_at,
579
578
  "reference_id": self.reference_id,
579
+ "payment_processing_config": self.payment_processing_config,
580
580
  }.to_json
581
581
  end
582
582
 
@@ -608,12 +608,6 @@ module ProcessOut
608
608
  if data.include? "customer_id"
609
609
  self.customer_id = data["customer_id"]
610
610
  end
611
- if data.include? "subscription"
612
- self.subscription = data["subscription"]
613
- end
614
- if data.include? "subscription_id"
615
- self.subscription_id = data["subscription_id"]
616
- end
617
611
  if data.include? "token"
618
612
  self.token = data["token"]
619
613
  end
@@ -626,6 +620,9 @@ module ProcessOut
626
620
  if data.include? "submerchant"
627
621
  self.submerchant = data["submerchant"]
628
622
  end
623
+ if data.include? "submerchant_id"
624
+ self.submerchant_id = data["submerchant_id"]
625
+ end
629
626
  if data.include? "url"
630
627
  self.url = data["url"]
631
628
  end
@@ -743,6 +740,9 @@ module ProcessOut
743
740
  if data.include? "reference_id"
744
741
  self.reference_id = data["reference_id"]
745
742
  end
743
+ if data.include? "payment_processing_config"
744
+ self.payment_processing_config = data["payment_processing_config"]
745
+ end
746
746
 
747
747
  self
748
748
  end
@@ -761,12 +761,11 @@ module ProcessOut
761
761
  self.transaction_id = data.fetch(:transaction_id, self.transaction_id)
762
762
  self.customer = data.fetch(:customer, self.customer)
763
763
  self.customer_id = data.fetch(:customer_id, self.customer_id)
764
- self.subscription = data.fetch(:subscription, self.subscription)
765
- self.subscription_id = data.fetch(:subscription_id, self.subscription_id)
766
764
  self.token = data.fetch(:token, self.token)
767
765
  self.token_id = data.fetch(:token_id, self.token_id)
768
766
  self.details = data.fetch(:details, self.details)
769
767
  self.submerchant = data.fetch(:submerchant, self.submerchant)
768
+ self.submerchant_id = data.fetch(:submerchant_id, self.submerchant_id)
770
769
  self.url = data.fetch(:url, self.url)
771
770
  self.url_qrcode = data.fetch(:url_qrcode, self.url_qrcode)
772
771
  self.name = data.fetch(:name, self.name)
@@ -806,10 +805,59 @@ module ProcessOut
806
805
  self.verification = data.fetch(:verification, self.verification)
807
806
  self.auto_capture_at = data.fetch(:auto_capture_at, self.auto_capture_at)
808
807
  self.reference_id = data.fetch(:reference_id, self.reference_id)
808
+ self.payment_processing_config = data.fetch(:payment_processing_config, self.payment_processing_config)
809
809
 
810
810
  self
811
811
  end
812
812
 
813
+ # Autheticate the invoice using the given source (customer or token)
814
+ # Params:
815
+ # +source+:: Source used to authenticate the payment. Can be a card, token or a gateway request.
816
+ # +options+:: +Hash+ of options
817
+ def authenticate(source, options = {})
818
+ self.prefill(options)
819
+
820
+ request = Request.new(@client)
821
+ path = "/invoices/:invoice_id/authenticate"
822
+ data = {
823
+ "device" => @device,
824
+ "incremental" => @incremental,
825
+ "synchronous" => options.fetch(:synchronous, nil),
826
+ "retry_drop_liability_shift" => options.fetch(:retry_drop_liability_shift, nil),
827
+ "capture_amount" => options.fetch(:capture_amount, nil),
828
+ "enable_three_d_s_2" => options.fetch(:enable_three_d_s_2, nil),
829
+ "allow_fallback_to_sale" => options.fetch(:allow_fallback_to_sale, nil),
830
+ "auto_capture_at" => options.fetch(:auto_capture_at, nil),
831
+ "metadata" => options.fetch(:metadata, nil),
832
+ "override_mac_blocking" => options.fetch(:override_mac_blocking, nil),
833
+ "external_three_d_s" => options.fetch(:external_three_d_s, nil),
834
+ "save_source" => options.fetch(:save_source, nil),
835
+ "provision_network_token" => options.fetch(:provision_network_token, nil),
836
+ "invoice_line_items" => options.fetch(:invoice_line_items, nil),
837
+ "transaction_link_id" => options.fetch(:transaction_link_id, nil),
838
+ "source" => source
839
+ }
840
+
841
+ response = Response.new(request.post(path, data, options))
842
+ return_values = Array.new
843
+
844
+ body = response.body
845
+ body = body.key?("transaction") ? body["transaction"] : nil
846
+ if !body.nil?
847
+ transaction = Transaction.new(@client)
848
+ return_values.push(transaction.fill_with_data(body))
849
+ end
850
+ body = response.body
851
+ body = body.key?("customer_action") ? body["customer_action"] : nil
852
+ if !body.nil?
853
+ customer_action = CustomerAction.new(@client)
854
+ return_values.push(customer_action.fill_with_data(body))
855
+ end
856
+
857
+
858
+ return_values
859
+ end
860
+
813
861
  # Create an incremental authorization
814
862
  # Params:
815
863
  # +amount+:: Amount to increment authorization by
@@ -860,6 +908,9 @@ module ProcessOut
860
908
  "override_mac_blocking" => options.fetch(:override_mac_blocking, nil),
861
909
  "external_three_d_s" => options.fetch(:external_three_d_s, nil),
862
910
  "save_source" => options.fetch(:save_source, nil),
911
+ "provision_network_token" => options.fetch(:provision_network_token, nil),
912
+ "invoice_line_items" => options.fetch(:invoice_line_items, nil),
913
+ "transaction_link_id" => options.fetch(:transaction_link_id, nil),
863
914
  "source" => source
864
915
  }
865
916
 
@@ -906,6 +957,8 @@ module ProcessOut
906
957
  "override_mac_blocking" => options.fetch(:override_mac_blocking, nil),
907
958
  "external_three_d_s" => options.fetch(:external_three_d_s, nil),
908
959
  "save_source" => options.fetch(:save_source, nil),
960
+ "provision_network_token" => options.fetch(:provision_network_token, nil),
961
+ "transaction_link_id" => options.fetch(:transaction_link_id, nil),
909
962
  "source" => source
910
963
  }
911
964
 
@@ -994,6 +1047,7 @@ module ProcessOut
994
1047
  path = "/invoices/" + CGI.escape(@id) + "/payout"
995
1048
  data = {
996
1049
  "force_gateway_configuration_id" => options.fetch(:force_gateway_configuration_id, nil),
1050
+ "metadata" => options.fetch(:metadata, nil),
997
1051
  "gateway_configuration_id" => gateway_configuration_id,
998
1052
  "source" => source
999
1053
  }
@@ -1202,6 +1256,7 @@ module ProcessOut
1202
1256
  "metadata" => @metadata,
1203
1257
  "details" => @details,
1204
1258
  "submerchant" => @submerchant,
1259
+ "submerchant_id" => @submerchant_id,
1205
1260
  "reference_id" => @reference_id,
1206
1261
  "exemption_reason_3ds2" => @exemption_reason_3ds2,
1207
1262
  "sca_exemption_reason" => @sca_exemption_reason,
@@ -9,6 +9,7 @@ module ProcessOut
9
9
  class InvoiceDevice
10
10
 
11
11
  attr_reader :channel
12
+ attr_reader :platform
12
13
  attr_reader :ip_address
13
14
  attr_reader :id
14
15
 
@@ -17,6 +18,10 @@ module ProcessOut
17
18
  @channel = val
18
19
  end
19
20
 
21
+ def platform=(val)
22
+ @platform = val
23
+ end
24
+
20
25
  def ip_address=(val)
21
26
  @ip_address = val
22
27
  end
@@ -34,6 +39,7 @@ module ProcessOut
34
39
  @client = client
35
40
 
36
41
  self.channel = data.fetch(:channel, nil)
42
+ self.platform = data.fetch(:platform, nil)
37
43
  self.ip_address = data.fetch(:ip_address, nil)
38
44
  self.id = data.fetch(:id, nil)
39
45
 
@@ -48,6 +54,7 @@ module ProcessOut
48
54
  def to_json(options)
49
55
  {
50
56
  "channel": self.channel,
57
+ "platform": self.platform,
51
58
  "ip_address": self.ip_address,
52
59
  "id": self.id,
53
60
  }.to_json
@@ -63,6 +70,9 @@ module ProcessOut
63
70
  if data.include? "channel"
64
71
  self.channel = data["channel"]
65
72
  end
73
+ if data.include? "platform"
74
+ self.platform = data["platform"]
75
+ end
66
76
  if data.include? "ip_address"
67
77
  self.ip_address = data["ip_address"]
68
78
  end
@@ -81,6 +91,7 @@ module ProcessOut
81
91
  return self
82
92
  end
83
93
  self.channel = data.fetch(:channel, self.channel)
94
+ self.platform = data.fetch(:platform, self.platform)
84
95
  self.ip_address = data.fetch(:ip_address, self.ip_address)
85
96
  self.id = data.fetch(:id, self.id)
86
97
 
@@ -11,6 +11,7 @@ module ProcessOut
11
11
  attr_reader :forter
12
12
  attr_reader :ravelin
13
13
  attr_reader :signifyd
14
+ attr_reader :riskified
14
15
 
15
16
 
16
17
  def forter=(val)
@@ -28,6 +29,11 @@ module ProcessOut
28
29
 
29
30
  end
30
31
 
32
+ def riskified=(val)
33
+ @riskified = val
34
+
35
+ end
36
+
31
37
 
32
38
  # Initializes the InvoiceExternalFraudTools object
33
39
  # Params:
@@ -39,6 +45,7 @@ module ProcessOut
39
45
  self.forter = data.fetch(:forter, nil)
40
46
  self.ravelin = data.fetch(:ravelin, nil)
41
47
  self.signifyd = data.fetch(:signifyd, nil)
48
+ self.riskified = data.fetch(:riskified, nil)
42
49
 
43
50
  end
44
51
 
@@ -53,6 +60,7 @@ module ProcessOut
53
60
  "forter": self.forter,
54
61
  "ravelin": self.ravelin,
55
62
  "signifyd": self.signifyd,
63
+ "riskified": self.riskified,
56
64
  }.to_json
57
65
  end
58
66
 
@@ -72,6 +80,9 @@ module ProcessOut
72
80
  if data.include? "signifyd"
73
81
  self.signifyd = data["signifyd"]
74
82
  end
83
+ if data.include? "riskified"
84
+ self.riskified = data["riskified"]
85
+ end
75
86
 
76
87
  self
77
88
  end
@@ -86,6 +97,7 @@ module ProcessOut
86
97
  self.forter = data.fetch(:forter, self.forter)
87
98
  self.ravelin = data.fetch(:ravelin, self.ravelin)
88
99
  self.signifyd = data.fetch(:signifyd, self.signifyd)
100
+ self.riskified = data.fetch(:riskified, self.riskified)
89
101
 
90
102
  self
91
103
  end
@@ -13,7 +13,7 @@ module ProcessOut
13
13
  req.basic_auth @client.project_id, @client.project_secret
14
14
  req.content_type = "application/json"
15
15
  req["API-Version"] = "1.4.0.0"
16
- req["User-Agent"] = "ProcessOut Ruby-Bindings/4.0.0"
16
+ req["User-Agent"] = "ProcessOut Ruby-Bindings/6.0.0"
17
17
 
18
18
  unless options.nil?
19
19
  req["Idempotency-Key"] = options.fetch(:idempotency_key, "")
@@ -0,0 +1,93 @@
1
+ # The content of this file was automatically generated
2
+
3
+ require "cgi"
4
+ require "json"
5
+ require "processout/networking/request"
6
+ require "processout/networking/response"
7
+
8
+ module ProcessOut
9
+ class PaymentProcessingConfiguration
10
+
11
+ attr_reader :bypass_unsupported_split_payments
12
+ attr_reader :apm_payment_config
13
+
14
+
15
+ def bypass_unsupported_split_payments=(val)
16
+ @bypass_unsupported_split_payments = val
17
+ end
18
+
19
+ def apm_payment_config=(val)
20
+ if val.nil?
21
+ @apm_payment_config = val
22
+ return
23
+ end
24
+
25
+ if val.instance_of? APMPaymentProcessingConfiguration
26
+ @apm_payment_config = val
27
+ else
28
+ obj = APMPaymentProcessingConfiguration.new(@client)
29
+ obj.fill_with_data(val)
30
+ @apm_payment_config = obj
31
+ end
32
+
33
+ end
34
+
35
+
36
+ # Initializes the PaymentProcessingConfiguration object
37
+ # Params:
38
+ # +client+:: +ProcessOut+ client instance
39
+ # +data+:: data that can be used to fill the object
40
+ def initialize(client, data = {})
41
+ @client = client
42
+
43
+ self.bypass_unsupported_split_payments = data.fetch(:bypass_unsupported_split_payments, nil)
44
+ self.apm_payment_config = data.fetch(:apm_payment_config, nil)
45
+
46
+ end
47
+
48
+ # Create a new PaymentProcessingConfiguration using the current client
49
+ def new(data = {})
50
+ PaymentProcessingConfiguration.new(@client, data)
51
+ end
52
+
53
+ # Overrides the JSON marshaller to only send the fields we want
54
+ def to_json(options)
55
+ {
56
+ "bypass_unsupported_split_payments": self.bypass_unsupported_split_payments,
57
+ "apm_payment_config": self.apm_payment_config,
58
+ }.to_json
59
+ end
60
+
61
+ # Fills the object with data coming from the API
62
+ # Params:
63
+ # +data+:: +Hash+ of data coming from the API
64
+ def fill_with_data(data)
65
+ if data.nil?
66
+ return self
67
+ end
68
+ if data.include? "bypass_unsupported_split_payments"
69
+ self.bypass_unsupported_split_payments = data["bypass_unsupported_split_payments"]
70
+ end
71
+ if data.include? "apm_payment_config"
72
+ self.apm_payment_config = data["apm_payment_config"]
73
+ end
74
+
75
+ self
76
+ end
77
+
78
+ # Prefills the object with the data passed as parameters
79
+ # Params:
80
+ # +data+:: +Hash+ of data
81
+ def prefill(data)
82
+ if data.nil?
83
+ return self
84
+ end
85
+ self.bypass_unsupported_split_payments = data.fetch(:bypass_unsupported_split_payments, self.bypass_unsupported_split_payments)
86
+ self.apm_payment_config = data.fetch(:apm_payment_config, self.apm_payment_config)
87
+
88
+ self
89
+ end
90
+
91
+
92
+ end
93
+ end
@@ -285,67 +285,6 @@ module ProcessOut
285
285
  return_values.push(response.success)
286
286
 
287
287
 
288
- return_values[0]
289
- end
290
-
291
- # Get all the supervised projects.
292
- # Params:
293
- # +options+:: +Hash+ of options
294
- def fetch_supervised(options = {})
295
- self.prefill(options)
296
-
297
- request = Request.new(@client)
298
- path = "/supervised-projects"
299
- data = {
300
-
301
- }
302
-
303
- response = Response.new(request.get(path, data, options))
304
- return_values = Array.new
305
-
306
- a = Array.new
307
- body = response.body
308
- for v in body['projects']
309
- tmp = Project.new(@client)
310
- tmp.fill_with_data(v)
311
- a.push(tmp)
312
- end
313
-
314
- return_values.push(a)
315
-
316
-
317
-
318
- return_values[0]
319
- end
320
-
321
- # Create a new supervised project.
322
- # Params:
323
- # +options+:: +Hash+ of options
324
- def create_supervised(options = {})
325
- self.prefill(options)
326
-
327
- request = Request.new(@client)
328
- path = "/supervised-projects"
329
- data = {
330
- "id" => @id,
331
- "name" => @name,
332
- "default_currency" => @default_currency,
333
- "dunning_configuration" => @dunning_configuration,
334
- "applepay_settings" => options.fetch(:applepay_settings, nil),
335
- "public_metadata" => options.fetch(:public_metadata, nil)
336
- }
337
-
338
- response = Response.new(request.post(path, data, options))
339
- return_values = Array.new
340
-
341
- body = response.body
342
- body = body.key?("project") ? body["project"] : nil
343
-
344
-
345
- return_values.push(self.fill_with_data(body))
346
-
347
-
348
-
349
288
  return_values[0]
350
289
  end
351
290
 
@@ -0,0 +1,92 @@
1
+ # The content of this file was automatically generated
2
+
3
+ require "cgi"
4
+ require "json"
5
+ require "processout/networking/request"
6
+ require "processout/networking/response"
7
+
8
+ module ProcessOut
9
+ class Submerchant
10
+
11
+ attr_reader :id
12
+ attr_reader :name
13
+ attr_reader :created_at
14
+
15
+
16
+ def id=(val)
17
+ @id = val
18
+ end
19
+
20
+ def name=(val)
21
+ @name = val
22
+ end
23
+
24
+ def created_at=(val)
25
+ @created_at = val
26
+ end
27
+
28
+
29
+ # Initializes the Submerchant object
30
+ # Params:
31
+ # +client+:: +ProcessOut+ client instance
32
+ # +data+:: data that can be used to fill the object
33
+ def initialize(client, data = {})
34
+ @client = client
35
+
36
+ self.id = data.fetch(:id, nil)
37
+ self.name = data.fetch(:name, nil)
38
+ self.created_at = data.fetch(:created_at, nil)
39
+
40
+ end
41
+
42
+ # Create a new Submerchant using the current client
43
+ def new(data = {})
44
+ Submerchant.new(@client, data)
45
+ end
46
+
47
+ # Overrides the JSON marshaller to only send the fields we want
48
+ def to_json(options)
49
+ {
50
+ "id": self.id,
51
+ "name": self.name,
52
+ "created_at": self.created_at,
53
+ }.to_json
54
+ end
55
+
56
+ # Fills the object with data coming from the API
57
+ # Params:
58
+ # +data+:: +Hash+ of data coming from the API
59
+ def fill_with_data(data)
60
+ if data.nil?
61
+ return self
62
+ end
63
+ if data.include? "id"
64
+ self.id = data["id"]
65
+ end
66
+ if data.include? "name"
67
+ self.name = data["name"]
68
+ end
69
+ if data.include? "created_at"
70
+ self.created_at = data["created_at"]
71
+ end
72
+
73
+ self
74
+ end
75
+
76
+ # Prefills the object with the data passed as parameters
77
+ # Params:
78
+ # +data+:: +Hash+ of data
79
+ def prefill(data)
80
+ if data.nil?
81
+ return self
82
+ end
83
+ self.id = data.fetch(:id, self.id)
84
+ self.name = data.fetch(:name, self.name)
85
+ self.created_at = data.fetch(:created_at, self.created_at)
86
+
87
+ self
88
+ end
89
+
90
+
91
+ end
92
+ end