processout 1.2.2 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/processout.rb +37 -0
- data/lib/processout/activity.rb +15 -0
- data/lib/processout/addon.rb +352 -0
- data/lib/processout/api_request.rb +274 -0
- data/lib/processout/api_version.rb +82 -0
- data/lib/processout/authorization_request.rb +62 -17
- data/lib/processout/card.rb +137 -10
- data/lib/processout/coupon.rb +22 -17
- data/lib/processout/customer.rb +180 -14
- data/lib/processout/discount.rb +69 -19
- data/lib/processout/dunning_action.rb +72 -0
- data/lib/processout/event.rb +15 -0
- data/lib/processout/gateway.rb +30 -0
- data/lib/processout/gateway_configuration.rb +90 -0
- data/lib/processout/gateway_request.rb +26 -0
- data/lib/processout/invoice.rb +119 -62
- data/lib/processout/invoice_detail.rb +20 -0
- data/lib/processout/networking/request.rb +1 -2
- data/lib/processout/plan.rb +15 -0
- data/lib/processout/product.rb +15 -0
- data/lib/processout/project.rb +100 -0
- data/lib/processout/refund.rb +32 -7
- data/lib/processout/subscription.rb +267 -117
- data/lib/processout/token.rb +62 -2
- data/lib/processout/transaction.rb +159 -0
- data/lib/processout/transaction_operation.rb +248 -0
- data/lib/processout/version.rb +1 -1
- data/lib/processout/webhook.rb +30 -0
- data/lib/processout/webhook_endpoint.rb +135 -0
- metadata +9 -2
@@ -0,0 +1,274 @@
|
|
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 APIRequest
|
9
|
+
|
10
|
+
attr_reader :id
|
11
|
+
attr_reader :project
|
12
|
+
attr_reader :api_version
|
13
|
+
attr_reader :idempotency_key
|
14
|
+
attr_reader :url
|
15
|
+
attr_reader :method
|
16
|
+
attr_reader :headers
|
17
|
+
attr_reader :body
|
18
|
+
attr_reader :response_code
|
19
|
+
attr_reader :response_headers
|
20
|
+
attr_reader :response_body
|
21
|
+
attr_reader :response_ms
|
22
|
+
attr_reader :sandbox
|
23
|
+
attr_reader :created_at
|
24
|
+
|
25
|
+
|
26
|
+
def id=(val)
|
27
|
+
@id = val
|
28
|
+
end
|
29
|
+
|
30
|
+
def project=(val)
|
31
|
+
if val.nil?
|
32
|
+
@project = val
|
33
|
+
return
|
34
|
+
end
|
35
|
+
|
36
|
+
if val.instance_of? Project
|
37
|
+
@project = val
|
38
|
+
else
|
39
|
+
obj = Project.new(@client)
|
40
|
+
obj.fill_with_data(val)
|
41
|
+
@project = obj
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
|
46
|
+
def api_version=(val)
|
47
|
+
if val.nil?
|
48
|
+
@api_version = val
|
49
|
+
return
|
50
|
+
end
|
51
|
+
|
52
|
+
if val.instance_of? APIVersion
|
53
|
+
@api_version = val
|
54
|
+
else
|
55
|
+
obj = APIVersion.new(@client)
|
56
|
+
obj.fill_with_data(val)
|
57
|
+
@api_version = obj
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
61
|
+
|
62
|
+
def idempotency_key=(val)
|
63
|
+
@idempotency_key = val
|
64
|
+
end
|
65
|
+
|
66
|
+
def url=(val)
|
67
|
+
@url = val
|
68
|
+
end
|
69
|
+
|
70
|
+
def method=(val)
|
71
|
+
@method = val
|
72
|
+
end
|
73
|
+
|
74
|
+
def headers=(val)
|
75
|
+
@headers = val
|
76
|
+
end
|
77
|
+
|
78
|
+
def body=(val)
|
79
|
+
@body = val
|
80
|
+
end
|
81
|
+
|
82
|
+
def response_code=(val)
|
83
|
+
@response_code = val
|
84
|
+
end
|
85
|
+
|
86
|
+
def response_headers=(val)
|
87
|
+
@response_headers = val
|
88
|
+
end
|
89
|
+
|
90
|
+
def response_body=(val)
|
91
|
+
@response_body = val
|
92
|
+
end
|
93
|
+
|
94
|
+
def response_ms=(val)
|
95
|
+
@response_ms = val
|
96
|
+
end
|
97
|
+
|
98
|
+
def sandbox=(val)
|
99
|
+
@sandbox = val
|
100
|
+
end
|
101
|
+
|
102
|
+
def created_at=(val)
|
103
|
+
@created_at = val
|
104
|
+
end
|
105
|
+
|
106
|
+
|
107
|
+
# Initializes the APIRequest object
|
108
|
+
# Params:
|
109
|
+
# +client+:: +ProcessOut+ client instance
|
110
|
+
# +data+:: data that can be used to fill the object
|
111
|
+
def initialize(client, data = {})
|
112
|
+
@client = client
|
113
|
+
|
114
|
+
self.id = data.fetch(:id, nil)
|
115
|
+
self.project = data.fetch(:project, nil)
|
116
|
+
self.api_version = data.fetch(:api_version, nil)
|
117
|
+
self.idempotency_key = data.fetch(:idempotency_key, nil)
|
118
|
+
self.url = data.fetch(:url, nil)
|
119
|
+
self.method = data.fetch(:method, nil)
|
120
|
+
self.headers = data.fetch(:headers, nil)
|
121
|
+
self.body = data.fetch(:body, nil)
|
122
|
+
self.response_code = data.fetch(:response_code, nil)
|
123
|
+
self.response_headers = data.fetch(:response_headers, nil)
|
124
|
+
self.response_body = data.fetch(:response_body, nil)
|
125
|
+
self.response_ms = data.fetch(:response_ms, nil)
|
126
|
+
self.sandbox = data.fetch(:sandbox, nil)
|
127
|
+
self.created_at = data.fetch(:created_at, nil)
|
128
|
+
|
129
|
+
end
|
130
|
+
|
131
|
+
# Create a new APIRequest using the current client
|
132
|
+
def new(data = {})
|
133
|
+
APIRequest.new(@client, data)
|
134
|
+
end
|
135
|
+
|
136
|
+
# Fills the object with data coming from the API
|
137
|
+
# Params:
|
138
|
+
# +data+:: +Hash+ of data coming from the API
|
139
|
+
def fill_with_data(data)
|
140
|
+
if data.nil?
|
141
|
+
return self
|
142
|
+
end
|
143
|
+
if data.include? "id"
|
144
|
+
self.id = data["id"]
|
145
|
+
end
|
146
|
+
if data.include? "project"
|
147
|
+
self.project = data["project"]
|
148
|
+
end
|
149
|
+
if data.include? "api_version"
|
150
|
+
self.api_version = data["api_version"]
|
151
|
+
end
|
152
|
+
if data.include? "idempotency_key"
|
153
|
+
self.idempotency_key = data["idempotency_key"]
|
154
|
+
end
|
155
|
+
if data.include? "url"
|
156
|
+
self.url = data["url"]
|
157
|
+
end
|
158
|
+
if data.include? "method"
|
159
|
+
self.method = data["method"]
|
160
|
+
end
|
161
|
+
if data.include? "headers"
|
162
|
+
self.headers = data["headers"]
|
163
|
+
end
|
164
|
+
if data.include? "body"
|
165
|
+
self.body = data["body"]
|
166
|
+
end
|
167
|
+
if data.include? "response_code"
|
168
|
+
self.response_code = data["response_code"]
|
169
|
+
end
|
170
|
+
if data.include? "response_headers"
|
171
|
+
self.response_headers = data["response_headers"]
|
172
|
+
end
|
173
|
+
if data.include? "response_body"
|
174
|
+
self.response_body = data["response_body"]
|
175
|
+
end
|
176
|
+
if data.include? "response_ms"
|
177
|
+
self.response_ms = data["response_ms"]
|
178
|
+
end
|
179
|
+
if data.include? "sandbox"
|
180
|
+
self.sandbox = data["sandbox"]
|
181
|
+
end
|
182
|
+
if data.include? "created_at"
|
183
|
+
self.created_at = data["created_at"]
|
184
|
+
end
|
185
|
+
|
186
|
+
self
|
187
|
+
end
|
188
|
+
|
189
|
+
# Prefills the object with the data passed as parameters
|
190
|
+
# Params:
|
191
|
+
# +data+:: +Hash+ of data
|
192
|
+
def prefill(data)
|
193
|
+
if data.nil?
|
194
|
+
return self
|
195
|
+
end
|
196
|
+
self.id = data.fetch(:id, self.id)
|
197
|
+
self.project = data.fetch(:project, self.project)
|
198
|
+
self.api_version = data.fetch(:api_version, self.api_version)
|
199
|
+
self.idempotency_key = data.fetch(:idempotency_key, self.idempotency_key)
|
200
|
+
self.url = data.fetch(:url, self.url)
|
201
|
+
self.method = data.fetch(:method, self.method)
|
202
|
+
self.headers = data.fetch(:headers, self.headers)
|
203
|
+
self.body = data.fetch(:body, self.body)
|
204
|
+
self.response_code = data.fetch(:response_code, self.response_code)
|
205
|
+
self.response_headers = data.fetch(:response_headers, self.response_headers)
|
206
|
+
self.response_body = data.fetch(:response_body, self.response_body)
|
207
|
+
self.response_ms = data.fetch(:response_ms, self.response_ms)
|
208
|
+
self.sandbox = data.fetch(:sandbox, self.sandbox)
|
209
|
+
self.created_at = data.fetch(:created_at, self.created_at)
|
210
|
+
|
211
|
+
self
|
212
|
+
end
|
213
|
+
|
214
|
+
# Get all the API requests.
|
215
|
+
# Params:
|
216
|
+
# +options+:: +Hash+ of options
|
217
|
+
def all(options = {})
|
218
|
+
self.prefill(options)
|
219
|
+
|
220
|
+
request = Request.new(@client)
|
221
|
+
path = "/api-requests"
|
222
|
+
data = {
|
223
|
+
|
224
|
+
}
|
225
|
+
|
226
|
+
response = Response.new(request.get(path, data, options))
|
227
|
+
return_values = Array.new
|
228
|
+
|
229
|
+
a = Array.new
|
230
|
+
body = response.body
|
231
|
+
for v in body['api_requests']
|
232
|
+
tmp = APIRequest.new(@client)
|
233
|
+
tmp.fill_with_data(v)
|
234
|
+
a.push(tmp)
|
235
|
+
end
|
236
|
+
|
237
|
+
return_values.push(a)
|
238
|
+
|
239
|
+
|
240
|
+
|
241
|
+
return_values[0]
|
242
|
+
end
|
243
|
+
|
244
|
+
# Find an API request by its ID.
|
245
|
+
# Params:
|
246
|
+
# +api_request_id+:: ID of the API request
|
247
|
+
# +options+:: +Hash+ of options
|
248
|
+
def find(api_request_id, options = {})
|
249
|
+
self.prefill(options)
|
250
|
+
|
251
|
+
request = Request.new(@client)
|
252
|
+
path = "/api-requests/{request_id}"
|
253
|
+
data = {
|
254
|
+
|
255
|
+
}
|
256
|
+
|
257
|
+
response = Response.new(request.get(path, data, options))
|
258
|
+
return_values = Array.new
|
259
|
+
|
260
|
+
body = response.body
|
261
|
+
body = body["api_request"]
|
262
|
+
|
263
|
+
|
264
|
+
obj = APIRequest.new(@client)
|
265
|
+
return_values.push(obj.fill_with_data(body))
|
266
|
+
|
267
|
+
|
268
|
+
|
269
|
+
return_values[0]
|
270
|
+
end
|
271
|
+
|
272
|
+
|
273
|
+
end
|
274
|
+
end
|
@@ -0,0 +1,82 @@
|
|
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 APIVersion
|
9
|
+
|
10
|
+
attr_reader :name
|
11
|
+
attr_reader :description
|
12
|
+
attr_reader :created_at
|
13
|
+
|
14
|
+
|
15
|
+
def name=(val)
|
16
|
+
@name = val
|
17
|
+
end
|
18
|
+
|
19
|
+
def description=(val)
|
20
|
+
@description = val
|
21
|
+
end
|
22
|
+
|
23
|
+
def created_at=(val)
|
24
|
+
@created_at = val
|
25
|
+
end
|
26
|
+
|
27
|
+
|
28
|
+
# Initializes the APIVersion object
|
29
|
+
# Params:
|
30
|
+
# +client+:: +ProcessOut+ client instance
|
31
|
+
# +data+:: data that can be used to fill the object
|
32
|
+
def initialize(client, data = {})
|
33
|
+
@client = client
|
34
|
+
|
35
|
+
self.name = data.fetch(:name, nil)
|
36
|
+
self.description = data.fetch(:description, nil)
|
37
|
+
self.created_at = data.fetch(:created_at, nil)
|
38
|
+
|
39
|
+
end
|
40
|
+
|
41
|
+
# Create a new APIVersion using the current client
|
42
|
+
def new(data = {})
|
43
|
+
APIVersion.new(@client, data)
|
44
|
+
end
|
45
|
+
|
46
|
+
# Fills the object with data coming from the API
|
47
|
+
# Params:
|
48
|
+
# +data+:: +Hash+ of data coming from the API
|
49
|
+
def fill_with_data(data)
|
50
|
+
if data.nil?
|
51
|
+
return self
|
52
|
+
end
|
53
|
+
if data.include? "name"
|
54
|
+
self.name = data["name"]
|
55
|
+
end
|
56
|
+
if data.include? "description"
|
57
|
+
self.description = data["description"]
|
58
|
+
end
|
59
|
+
if data.include? "created_at"
|
60
|
+
self.created_at = data["created_at"]
|
61
|
+
end
|
62
|
+
|
63
|
+
self
|
64
|
+
end
|
65
|
+
|
66
|
+
# Prefills the object with the data passed as parameters
|
67
|
+
# Params:
|
68
|
+
# +data+:: +Hash+ of data
|
69
|
+
def prefill(data)
|
70
|
+
if data.nil?
|
71
|
+
return self
|
72
|
+
end
|
73
|
+
self.name = data.fetch(:name, self.name)
|
74
|
+
self.description = data.fetch(:description, self.description)
|
75
|
+
self.created_at = data.fetch(:created_at, self.created_at)
|
76
|
+
|
77
|
+
self
|
78
|
+
end
|
79
|
+
|
80
|
+
|
81
|
+
end
|
82
|
+
end
|
@@ -9,15 +9,18 @@ module ProcessOut
|
|
9
9
|
|
10
10
|
attr_reader :id
|
11
11
|
attr_reader :project
|
12
|
+
attr_reader :project_id
|
12
13
|
attr_reader :customer
|
14
|
+
attr_reader :customer_id
|
13
15
|
attr_reader :token
|
14
|
-
attr_reader :
|
15
|
-
attr_reader :authorized
|
16
|
+
attr_reader :token_id
|
16
17
|
attr_reader :name
|
17
18
|
attr_reader :currency
|
18
19
|
attr_reader :return_url
|
19
20
|
attr_reader :cancel_url
|
21
|
+
attr_reader :authorized
|
20
22
|
attr_reader :sandbox
|
23
|
+
attr_reader :url
|
21
24
|
attr_reader :created_at
|
22
25
|
|
23
26
|
|
@@ -26,6 +29,11 @@ module ProcessOut
|
|
26
29
|
end
|
27
30
|
|
28
31
|
def project=(val)
|
32
|
+
if val.nil?
|
33
|
+
@project = val
|
34
|
+
return
|
35
|
+
end
|
36
|
+
|
29
37
|
if val.instance_of? Project
|
30
38
|
@project = val
|
31
39
|
else
|
@@ -36,7 +44,16 @@ module ProcessOut
|
|
36
44
|
|
37
45
|
end
|
38
46
|
|
47
|
+
def project_id=(val)
|
48
|
+
@project_id = val
|
49
|
+
end
|
50
|
+
|
39
51
|
def customer=(val)
|
52
|
+
if val.nil?
|
53
|
+
@customer = val
|
54
|
+
return
|
55
|
+
end
|
56
|
+
|
40
57
|
if val.instance_of? Customer
|
41
58
|
@customer = val
|
42
59
|
else
|
@@ -47,7 +64,16 @@ module ProcessOut
|
|
47
64
|
|
48
65
|
end
|
49
66
|
|
67
|
+
def customer_id=(val)
|
68
|
+
@customer_id = val
|
69
|
+
end
|
70
|
+
|
50
71
|
def token=(val)
|
72
|
+
if val.nil?
|
73
|
+
@token = val
|
74
|
+
return
|
75
|
+
end
|
76
|
+
|
51
77
|
if val.instance_of? Token
|
52
78
|
@token = val
|
53
79
|
else
|
@@ -58,12 +84,8 @@ module ProcessOut
|
|
58
84
|
|
59
85
|
end
|
60
86
|
|
61
|
-
def
|
62
|
-
@
|
63
|
-
end
|
64
|
-
|
65
|
-
def authorized=(val)
|
66
|
-
@authorized = val
|
87
|
+
def token_id=(val)
|
88
|
+
@token_id = val
|
67
89
|
end
|
68
90
|
|
69
91
|
def name=(val)
|
@@ -82,10 +104,18 @@ module ProcessOut
|
|
82
104
|
@cancel_url = val
|
83
105
|
end
|
84
106
|
|
107
|
+
def authorized=(val)
|
108
|
+
@authorized = val
|
109
|
+
end
|
110
|
+
|
85
111
|
def sandbox=(val)
|
86
112
|
@sandbox = val
|
87
113
|
end
|
88
114
|
|
115
|
+
def url=(val)
|
116
|
+
@url = val
|
117
|
+
end
|
118
|
+
|
89
119
|
def created_at=(val)
|
90
120
|
@created_at = val
|
91
121
|
end
|
@@ -100,15 +130,18 @@ module ProcessOut
|
|
100
130
|
|
101
131
|
self.id = data.fetch(:id, nil)
|
102
132
|
self.project = data.fetch(:project, nil)
|
133
|
+
self.project_id = data.fetch(:project_id, nil)
|
103
134
|
self.customer = data.fetch(:customer, nil)
|
135
|
+
self.customer_id = data.fetch(:customer_id, nil)
|
104
136
|
self.token = data.fetch(:token, nil)
|
105
|
-
self.
|
106
|
-
self.authorized = data.fetch(:authorized, nil)
|
137
|
+
self.token_id = data.fetch(:token_id, nil)
|
107
138
|
self.name = data.fetch(:name, nil)
|
108
139
|
self.currency = data.fetch(:currency, nil)
|
109
140
|
self.return_url = data.fetch(:return_url, nil)
|
110
141
|
self.cancel_url = data.fetch(:cancel_url, nil)
|
142
|
+
self.authorized = data.fetch(:authorized, nil)
|
111
143
|
self.sandbox = data.fetch(:sandbox, nil)
|
144
|
+
self.url = data.fetch(:url, nil)
|
112
145
|
self.created_at = data.fetch(:created_at, nil)
|
113
146
|
|
114
147
|
end
|
@@ -131,17 +164,20 @@ module ProcessOut
|
|
131
164
|
if data.include? "project"
|
132
165
|
self.project = data["project"]
|
133
166
|
end
|
167
|
+
if data.include? "project_id"
|
168
|
+
self.project_id = data["project_id"]
|
169
|
+
end
|
134
170
|
if data.include? "customer"
|
135
171
|
self.customer = data["customer"]
|
136
172
|
end
|
173
|
+
if data.include? "customer_id"
|
174
|
+
self.customer_id = data["customer_id"]
|
175
|
+
end
|
137
176
|
if data.include? "token"
|
138
177
|
self.token = data["token"]
|
139
178
|
end
|
140
|
-
if data.include? "
|
141
|
-
self.
|
142
|
-
end
|
143
|
-
if data.include? "authorized"
|
144
|
-
self.authorized = data["authorized"]
|
179
|
+
if data.include? "token_id"
|
180
|
+
self.token_id = data["token_id"]
|
145
181
|
end
|
146
182
|
if data.include? "name"
|
147
183
|
self.name = data["name"]
|
@@ -155,9 +191,15 @@ module ProcessOut
|
|
155
191
|
if data.include? "cancel_url"
|
156
192
|
self.cancel_url = data["cancel_url"]
|
157
193
|
end
|
194
|
+
if data.include? "authorized"
|
195
|
+
self.authorized = data["authorized"]
|
196
|
+
end
|
158
197
|
if data.include? "sandbox"
|
159
198
|
self.sandbox = data["sandbox"]
|
160
199
|
end
|
200
|
+
if data.include? "url"
|
201
|
+
self.url = data["url"]
|
202
|
+
end
|
161
203
|
if data.include? "created_at"
|
162
204
|
self.created_at = data["created_at"]
|
163
205
|
end
|
@@ -174,15 +216,18 @@ module ProcessOut
|
|
174
216
|
end
|
175
217
|
self.id = data.fetch(:id, self.id)
|
176
218
|
self.project = data.fetch(:project, self.project)
|
219
|
+
self.project_id = data.fetch(:project_id, self.project_id)
|
177
220
|
self.customer = data.fetch(:customer, self.customer)
|
221
|
+
self.customer_id = data.fetch(:customer_id, self.customer_id)
|
178
222
|
self.token = data.fetch(:token, self.token)
|
179
|
-
self.
|
180
|
-
self.authorized = data.fetch(:authorized, self.authorized)
|
223
|
+
self.token_id = data.fetch(:token_id, self.token_id)
|
181
224
|
self.name = data.fetch(:name, self.name)
|
182
225
|
self.currency = data.fetch(:currency, self.currency)
|
183
226
|
self.return_url = data.fetch(:return_url, self.return_url)
|
184
227
|
self.cancel_url = data.fetch(:cancel_url, self.cancel_url)
|
228
|
+
self.authorized = data.fetch(:authorized, self.authorized)
|
185
229
|
self.sandbox = data.fetch(:sandbox, self.sandbox)
|
230
|
+
self.url = data.fetch(:url, self.url)
|
186
231
|
self.created_at = data.fetch(:created_at, self.created_at)
|
187
232
|
|
188
233
|
self
|