processout 1.2.2 → 2.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.
@@ -9,8 +9,12 @@ module ProcessOut
9
9
 
10
10
  attr_reader :id
11
11
  attr_reader :project
12
+ attr_reader :project_id
12
13
  attr_reader :subscription
14
+ attr_reader :subscription_id
13
15
  attr_reader :coupon
16
+ attr_reader :coupon_id
17
+ attr_reader :name
14
18
  attr_reader :amount
15
19
  attr_reader :percent
16
20
  attr_reader :expires_at
@@ -24,6 +28,11 @@ module ProcessOut
24
28
  end
25
29
 
26
30
  def project=(val)
31
+ if val.nil?
32
+ @project = val
33
+ return
34
+ end
35
+
27
36
  if val.instance_of? Project
28
37
  @project = val
29
38
  else
@@ -34,7 +43,16 @@ module ProcessOut
34
43
 
35
44
  end
36
45
 
46
+ def project_id=(val)
47
+ @project_id = val
48
+ end
49
+
37
50
  def subscription=(val)
51
+ if val.nil?
52
+ @subscription = val
53
+ return
54
+ end
55
+
38
56
  if val.instance_of? Subscription
39
57
  @subscription = val
40
58
  else
@@ -45,7 +63,16 @@ module ProcessOut
45
63
 
46
64
  end
47
65
 
66
+ def subscription_id=(val)
67
+ @subscription_id = val
68
+ end
69
+
48
70
  def coupon=(val)
71
+ if val.nil?
72
+ @coupon = val
73
+ return
74
+ end
75
+
49
76
  if val.instance_of? Coupon
50
77
  @coupon = val
51
78
  else
@@ -56,6 +83,14 @@ module ProcessOut
56
83
 
57
84
  end
58
85
 
86
+ def coupon_id=(val)
87
+ @coupon_id = val
88
+ end
89
+
90
+ def name=(val)
91
+ @name = val
92
+ end
93
+
59
94
  def amount=(val)
60
95
  @amount = val
61
96
  end
@@ -90,8 +125,12 @@ module ProcessOut
90
125
 
91
126
  self.id = data.fetch(:id, nil)
92
127
  self.project = data.fetch(:project, nil)
128
+ self.project_id = data.fetch(:project_id, nil)
93
129
  self.subscription = data.fetch(:subscription, nil)
130
+ self.subscription_id = data.fetch(:subscription_id, nil)
94
131
  self.coupon = data.fetch(:coupon, nil)
132
+ self.coupon_id = data.fetch(:coupon_id, nil)
133
+ self.name = data.fetch(:name, nil)
95
134
  self.amount = data.fetch(:amount, nil)
96
135
  self.percent = data.fetch(:percent, nil)
97
136
  self.expires_at = data.fetch(:expires_at, nil)
@@ -119,12 +158,24 @@ module ProcessOut
119
158
  if data.include? "project"
120
159
  self.project = data["project"]
121
160
  end
161
+ if data.include? "project_id"
162
+ self.project_id = data["project_id"]
163
+ end
122
164
  if data.include? "subscription"
123
165
  self.subscription = data["subscription"]
124
166
  end
167
+ if data.include? "subscription_id"
168
+ self.subscription_id = data["subscription_id"]
169
+ end
125
170
  if data.include? "coupon"
126
171
  self.coupon = data["coupon"]
127
172
  end
173
+ if data.include? "coupon_id"
174
+ self.coupon_id = data["coupon_id"]
175
+ end
176
+ if data.include? "name"
177
+ self.name = data["name"]
178
+ end
128
179
  if data.include? "amount"
129
180
  self.amount = data["amount"]
130
181
  end
@@ -156,8 +207,12 @@ module ProcessOut
156
207
  end
157
208
  self.id = data.fetch(:id, self.id)
158
209
  self.project = data.fetch(:project, self.project)
210
+ self.project_id = data.fetch(:project_id, self.project_id)
159
211
  self.subscription = data.fetch(:subscription, self.subscription)
212
+ self.subscription_id = data.fetch(:subscription_id, self.subscription_id)
160
213
  self.coupon = data.fetch(:coupon, self.coupon)
214
+ self.coupon_id = data.fetch(:coupon_id, self.coupon_id)
215
+ self.name = data.fetch(:name, self.name)
161
216
  self.amount = data.fetch(:amount, self.amount)
162
217
  self.percent = data.fetch(:percent, self.percent)
163
218
  self.expires_at = data.fetch(:expires_at, self.expires_at)
@@ -178,10 +233,11 @@ module ProcessOut
178
233
  request = Request.new(@client)
179
234
  path = "/subscriptions/" + CGI.escape(subscription_id) + "/discounts"
180
235
  data = {
236
+ "coupon_id" => @coupon_id,
237
+ "name" => @name,
181
238
  "amount" => @amount,
182
239
  "expires_at" => @expires_at,
183
- "metadata" => @metadata,
184
- "coupon_id" => options.fetch(:coupon_id, nil)
240
+ "metadata" => @metadata
185
241
  }
186
242
 
187
243
  response = Response.new(request.post(path, data, options))
@@ -198,21 +254,21 @@ module ProcessOut
198
254
  return_values[0]
199
255
  end
200
256
 
201
- # Apply a new discount on the subscription from a coupon ID.
257
+ # Find a subscription's discount by its ID.
202
258
  # Params:
203
- # +subscription_id+:: ID of the subscription
204
- # +coupon_id+:: ID of the coupon
259
+ # +subscription_id+:: ID of the subscription on which the discount was applied
260
+ # +discount_id+:: ID of the discount
205
261
  # +options+:: +Hash+ of options
206
- def apply_coupon(subscription_id, coupon_id, options = {})
262
+ def find(subscription_id, discount_id, options = {})
207
263
  self.prefill(options)
208
264
 
209
265
  request = Request.new(@client)
210
- path = "/subscriptions/" + CGI.escape(subscription_id) + "/discounts"
266
+ path = "/subscriptions/" + CGI.escape(subscription_id) + "/discounts/" + CGI.escape(discount_id) + ""
211
267
  data = {
212
- "coupon_id" => coupon_id
268
+
213
269
  }
214
270
 
215
- response = Response.new(request.post(path, data, options))
271
+ response = Response.new(request.get(path, data, options))
216
272
  return_values = Array.new
217
273
 
218
274
  body = response.body
@@ -227,12 +283,12 @@ module ProcessOut
227
283
  return_values[0]
228
284
  end
229
285
 
230
- # Find a subscription's discount by its ID.
286
+ # Remove a discount applied to a subscription.
231
287
  # Params:
232
288
  # +subscription_id+:: ID of the subscription on which the discount was applied
233
289
  # +discount_id+:: ID of the discount
234
290
  # +options+:: +Hash+ of options
235
- def find(subscription_id, discount_id, options = {})
291
+ def remove(subscription_id, discount_id, options = {})
236
292
  self.prefill(options)
237
293
 
238
294
  request = Request.new(@client)
@@ -241,16 +297,10 @@ module ProcessOut
241
297
 
242
298
  }
243
299
 
244
- response = Response.new(request.get(path, data, options))
300
+ response = Response.new(request.delete(path, data, options))
245
301
  return_values = Array.new
246
302
 
247
- body = response.body
248
- body = body["discount"]
249
-
250
-
251
- obj = Discount.new(@client)
252
- return_values.push(obj.fill_with_data(body))
253
-
303
+ return_values.push(response.success)
254
304
 
255
305
 
256
306
  return_values[0]
@@ -0,0 +1,72 @@
1
+ # The content of this file was automatically generated
2
+
3
+ require "cgi"
4
+ require "processout/networking/request"
5
+ require "processout/networking/response"
6
+
7
+ module ProcessOut
8
+ class DunningAction
9
+
10
+ attr_reader :action
11
+ attr_reader :delay_in_days
12
+
13
+
14
+ def action=(val)
15
+ @action = val
16
+ end
17
+
18
+ def delay_in_days=(val)
19
+ @delay_in_days = val
20
+ end
21
+
22
+
23
+ # Initializes the DunningAction object
24
+ # Params:
25
+ # +client+:: +ProcessOut+ client instance
26
+ # +data+:: data that can be used to fill the object
27
+ def initialize(client, data = {})
28
+ @client = client
29
+
30
+ self.action = data.fetch(:action, nil)
31
+ self.delay_in_days = data.fetch(:delay_in_days, nil)
32
+
33
+ end
34
+
35
+ # Create a new DunningAction using the current client
36
+ def new(data = {})
37
+ DunningAction.new(@client, data)
38
+ end
39
+
40
+ # Fills the object with data coming from the API
41
+ # Params:
42
+ # +data+:: +Hash+ of data coming from the API
43
+ def fill_with_data(data)
44
+ if data.nil?
45
+ return self
46
+ end
47
+ if data.include? "action"
48
+ self.action = data["action"]
49
+ end
50
+ if data.include? "delay_in_days"
51
+ self.delay_in_days = data["delay_in_days"]
52
+ end
53
+
54
+ self
55
+ end
56
+
57
+ # Prefills the object with the data passed as parameters
58
+ # Params:
59
+ # +data+:: +Hash+ of data
60
+ def prefill(data)
61
+ if data.nil?
62
+ return self
63
+ end
64
+ self.action = data.fetch(:action, self.action)
65
+ self.delay_in_days = data.fetch(:delay_in_days, self.delay_in_days)
66
+
67
+ self
68
+ end
69
+
70
+
71
+ end
72
+ end
@@ -9,6 +9,7 @@ module ProcessOut
9
9
 
10
10
  attr_reader :id
11
11
  attr_reader :project
12
+ attr_reader :project_id
12
13
  attr_reader :name
13
14
  attr_reader :data
14
15
  attr_reader :sandbox
@@ -20,6 +21,11 @@ module ProcessOut
20
21
  end
21
22
 
22
23
  def project=(val)
24
+ if val.nil?
25
+ @project = val
26
+ return
27
+ end
28
+
23
29
  if val.instance_of? Project
24
30
  @project = val
25
31
  else
@@ -30,6 +36,10 @@ module ProcessOut
30
36
 
31
37
  end
32
38
 
39
+ def project_id=(val)
40
+ @project_id = val
41
+ end
42
+
33
43
  def name=(val)
34
44
  @name = val
35
45
  end
@@ -57,6 +67,7 @@ module ProcessOut
57
67
 
58
68
  self.id = data.fetch(:id, nil)
59
69
  self.project = data.fetch(:project, nil)
70
+ self.project_id = data.fetch(:project_id, nil)
60
71
  self.name = data.fetch(:name, nil)
61
72
  self.data = data.fetch(:data, nil)
62
73
  self.sandbox = data.fetch(:sandbox, nil)
@@ -82,6 +93,9 @@ module ProcessOut
82
93
  if data.include? "project"
83
94
  self.project = data["project"]
84
95
  end
96
+ if data.include? "project_id"
97
+ self.project_id = data["project_id"]
98
+ end
85
99
  if data.include? "name"
86
100
  self.name = data["name"]
87
101
  end
@@ -107,6 +121,7 @@ module ProcessOut
107
121
  end
108
122
  self.id = data.fetch(:id, self.id)
109
123
  self.project = data.fetch(:project, self.project)
124
+ self.project_id = data.fetch(:project_id, self.project_id)
110
125
  self.name = data.fetch(:name, self.name)
111
126
  self.data = data.fetch(:data, self.data)
112
127
  self.sandbox = data.fetch(:sandbox, self.sandbox)
@@ -14,6 +14,9 @@ module ProcessOut
14
14
  attr_reader :url
15
15
  attr_reader :flows
16
16
  attr_reader :tags
17
+ attr_reader :can_pull_transactions
18
+ attr_reader :can_refund
19
+ attr_reader :is_oauth_authentication
17
20
  attr_reader :description
18
21
 
19
22
 
@@ -45,6 +48,18 @@ module ProcessOut
45
48
  @tags = val
46
49
  end
47
50
 
51
+ def can_pull_transactions=(val)
52
+ @can_pull_transactions = val
53
+ end
54
+
55
+ def can_refund=(val)
56
+ @can_refund = val
57
+ end
58
+
59
+ def is_oauth_authentication=(val)
60
+ @is_oauth_authentication = val
61
+ end
62
+
48
63
  def description=(val)
49
64
  @description = val
50
65
  end
@@ -64,6 +79,9 @@ module ProcessOut
64
79
  self.url = data.fetch(:url, nil)
65
80
  self.flows = data.fetch(:flows, nil)
66
81
  self.tags = data.fetch(:tags, nil)
82
+ self.can_pull_transactions = data.fetch(:can_pull_transactions, nil)
83
+ self.can_refund = data.fetch(:can_refund, nil)
84
+ self.is_oauth_authentication = data.fetch(:is_oauth_authentication, nil)
67
85
  self.description = data.fetch(:description, nil)
68
86
 
69
87
  end
@@ -101,6 +119,15 @@ module ProcessOut
101
119
  if data.include? "tags"
102
120
  self.tags = data["tags"]
103
121
  end
122
+ if data.include? "can_pull_transactions"
123
+ self.can_pull_transactions = data["can_pull_transactions"]
124
+ end
125
+ if data.include? "can_refund"
126
+ self.can_refund = data["can_refund"]
127
+ end
128
+ if data.include? "is_oauth_authentication"
129
+ self.is_oauth_authentication = data["is_oauth_authentication"]
130
+ end
104
131
  if data.include? "description"
105
132
  self.description = data["description"]
106
133
  end
@@ -122,6 +149,9 @@ module ProcessOut
122
149
  self.url = data.fetch(:url, self.url)
123
150
  self.flows = data.fetch(:flows, self.flows)
124
151
  self.tags = data.fetch(:tags, self.tags)
152
+ self.can_pull_transactions = data.fetch(:can_pull_transactions, self.can_pull_transactions)
153
+ self.can_refund = data.fetch(:can_refund, self.can_refund)
154
+ self.is_oauth_authentication = data.fetch(:is_oauth_authentication, self.is_oauth_authentication)
125
155
  self.description = data.fetch(:description, self.description)
126
156
 
127
157
  self
@@ -9,9 +9,17 @@ module ProcessOut
9
9
 
10
10
  attr_reader :id
11
11
  attr_reader :project
12
+ attr_reader :project_id
12
13
  attr_reader :gateway
14
+ attr_reader :gateway_id
15
+ attr_reader :name
16
+ attr_reader :fee_fixed
17
+ attr_reader :fee_percentage
18
+ attr_reader :default_currency
13
19
  attr_reader :enabled
14
20
  attr_reader :public_keys
21
+ attr_reader :created_at
22
+ attr_reader :enabled_at
15
23
 
16
24
 
17
25
  def id=(val)
@@ -19,6 +27,11 @@ module ProcessOut
19
27
  end
20
28
 
21
29
  def project=(val)
30
+ if val.nil?
31
+ @project = val
32
+ return
33
+ end
34
+
22
35
  if val.instance_of? Project
23
36
  @project = val
24
37
  else
@@ -29,7 +42,16 @@ module ProcessOut
29
42
 
30
43
  end
31
44
 
45
+ def project_id=(val)
46
+ @project_id = val
47
+ end
48
+
32
49
  def gateway=(val)
50
+ if val.nil?
51
+ @gateway = val
52
+ return
53
+ end
54
+
33
55
  if val.instance_of? Gateway
34
56
  @gateway = val
35
57
  else
@@ -40,6 +62,26 @@ module ProcessOut
40
62
 
41
63
  end
42
64
 
65
+ def gateway_id=(val)
66
+ @gateway_id = val
67
+ end
68
+
69
+ def name=(val)
70
+ @name = val
71
+ end
72
+
73
+ def fee_fixed=(val)
74
+ @fee_fixed = val
75
+ end
76
+
77
+ def fee_percentage=(val)
78
+ @fee_percentage = val
79
+ end
80
+
81
+ def default_currency=(val)
82
+ @default_currency = val
83
+ end
84
+
43
85
  def enabled=(val)
44
86
  @enabled = val
45
87
  end
@@ -48,6 +90,14 @@ module ProcessOut
48
90
  @public_keys = val
49
91
  end
50
92
 
93
+ def created_at=(val)
94
+ @created_at = val
95
+ end
96
+
97
+ def enabled_at=(val)
98
+ @enabled_at = val
99
+ end
100
+
51
101
 
52
102
  # Initializes the GatewayConfiguration object
53
103
  # Params:
@@ -58,9 +108,17 @@ module ProcessOut
58
108
 
59
109
  self.id = data.fetch(:id, nil)
60
110
  self.project = data.fetch(:project, nil)
111
+ self.project_id = data.fetch(:project_id, nil)
61
112
  self.gateway = data.fetch(:gateway, nil)
113
+ self.gateway_id = data.fetch(:gateway_id, nil)
114
+ self.name = data.fetch(:name, nil)
115
+ self.fee_fixed = data.fetch(:fee_fixed, nil)
116
+ self.fee_percentage = data.fetch(:fee_percentage, nil)
117
+ self.default_currency = data.fetch(:default_currency, nil)
62
118
  self.enabled = data.fetch(:enabled, nil)
63
119
  self.public_keys = data.fetch(:public_keys, nil)
120
+ self.created_at = data.fetch(:created_at, nil)
121
+ self.enabled_at = data.fetch(:enabled_at, nil)
64
122
 
65
123
  end
66
124
 
@@ -82,15 +140,39 @@ module ProcessOut
82
140
  if data.include? "project"
83
141
  self.project = data["project"]
84
142
  end
143
+ if data.include? "project_id"
144
+ self.project_id = data["project_id"]
145
+ end
85
146
  if data.include? "gateway"
86
147
  self.gateway = data["gateway"]
87
148
  end
149
+ if data.include? "gateway_id"
150
+ self.gateway_id = data["gateway_id"]
151
+ end
152
+ if data.include? "name"
153
+ self.name = data["name"]
154
+ end
155
+ if data.include? "fee_fixed"
156
+ self.fee_fixed = data["fee_fixed"]
157
+ end
158
+ if data.include? "fee_percentage"
159
+ self.fee_percentage = data["fee_percentage"]
160
+ end
161
+ if data.include? "default_currency"
162
+ self.default_currency = data["default_currency"]
163
+ end
88
164
  if data.include? "enabled"
89
165
  self.enabled = data["enabled"]
90
166
  end
91
167
  if data.include? "public_keys"
92
168
  self.public_keys = data["public_keys"]
93
169
  end
170
+ if data.include? "created_at"
171
+ self.created_at = data["created_at"]
172
+ end
173
+ if data.include? "enabled_at"
174
+ self.enabled_at = data["enabled_at"]
175
+ end
94
176
 
95
177
  self
96
178
  end
@@ -104,9 +186,17 @@ module ProcessOut
104
186
  end
105
187
  self.id = data.fetch(:id, self.id)
106
188
  self.project = data.fetch(:project, self.project)
189
+ self.project_id = data.fetch(:project_id, self.project_id)
107
190
  self.gateway = data.fetch(:gateway, self.gateway)
191
+ self.gateway_id = data.fetch(:gateway_id, self.gateway_id)
192
+ self.name = data.fetch(:name, self.name)
193
+ self.fee_fixed = data.fetch(:fee_fixed, self.fee_fixed)
194
+ self.fee_percentage = data.fetch(:fee_percentage, self.fee_percentage)
195
+ self.default_currency = data.fetch(:default_currency, self.default_currency)
108
196
  self.enabled = data.fetch(:enabled, self.enabled)
109
197
  self.public_keys = data.fetch(:public_keys, self.public_keys)
198
+ self.created_at = data.fetch(:created_at, self.created_at)
199
+ self.enabled_at = data.fetch(:enabled_at, self.enabled_at)
110
200
 
111
201
  self
112
202
  end