processout 0.2.1 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -45,17 +45,23 @@ module ProcessOut
45
45
  # Initializes the Token object
46
46
  # Params:
47
47
  # +client+:: +ProcessOut+ client instance
48
- def initialize(client)
48
+ # +data+:: data that can be used to fill the object
49
+ def initialize(client, data = {})
49
50
  @client = client
50
51
 
51
- @id = ""
52
- @customer = nil
53
- @metadata = Hash.new
54
- @is_subscription_only = false
55
- @created_at = ""
52
+ @id = data.fetch(:id, "")
53
+ @customer = data.fetch(:customer, nil)
54
+ @metadata = data.fetch(:metadata, Hash.new)
55
+ @is_subscription_only = data.fetch(:is_subscription_only, false)
56
+ @created_at = data.fetch(:created_at, "")
56
57
 
57
58
  end
58
59
 
60
+ # Create a new Token using the current client
61
+ def new(data = {})
62
+ Token.new(@client, data)
63
+ end
64
+
59
65
  # Fills the object with data coming from the API
60
66
  # Params:
61
67
  # +data+:: +Hash+ of data coming from the API
@@ -84,7 +90,7 @@ module ProcessOut
84
90
  # +customer_id+:: ID of the customer
85
91
  # +token_id+:: ID of the token
86
92
  # +options+:: +Hash+ of options
87
- def find(customer_id, token_id, options = nil)
93
+ def find(customer_id, token_id, options = {})
88
94
  request = Request.new(@client)
89
95
  path = "/customers/" + CGI.escape(customer_id) + "/tokens/" + CGI.escape(token_id) + ""
90
96
  data = {
@@ -111,7 +117,7 @@ module ProcessOut
111
117
  # +customer_id+:: ID of the customer
112
118
  # +source+:: Source used to create the token (most likely a card token generated by ProcessOut.js)
113
119
  # +options+:: +Hash+ of options
114
- def create(customer_id, source, options = nil)
120
+ def create(customer_id, source, options = {})
115
121
  request = Request.new(@client)
116
122
  path = "/customers/" + CGI.escape(customer_id) + "/tokens"
117
123
  data = {
@@ -139,7 +145,7 @@ module ProcessOut
139
145
  # +source+:: Source used to create the token (most likely a card token generated by ProcessOut.js)
140
146
  # +target+:: Authorization request ID
141
147
  # +options+:: +Hash+ of options
142
- def create_from_request(customer_id, source, target, options = nil)
148
+ def create_from_request(customer_id, source, target, options = {})
143
149
  request = Request.new(@client)
144
150
  path = "/customers/" + CGI.escape(customer_id) + "/tokens"
145
151
  data = {
@@ -133,29 +133,35 @@ module ProcessOut
133
133
  # Initializes the Transaction object
134
134
  # Params:
135
135
  # +client+:: +ProcessOut+ client instance
136
- def initialize(client)
136
+ # +data+:: data that can be used to fill the object
137
+ def initialize(client, data = {})
137
138
  @client = client
138
139
 
139
- @id = ""
140
- @project = nil
141
- @subscription = nil
142
- @customer = nil
143
- @token = nil
144
- @card = nil
145
- @name = ""
146
- @authorized_amount = ""
147
- @captured_amount = ""
148
- @currency = ""
149
- @status = ""
150
- @authorized = false
151
- @captured = false
152
- @processout_fee = ""
153
- @metadata = Hash.new
154
- @sandbox = false
155
- @created_at = ""
140
+ @id = data.fetch(:id, "")
141
+ @project = data.fetch(:project, nil)
142
+ @subscription = data.fetch(:subscription, nil)
143
+ @customer = data.fetch(:customer, nil)
144
+ @token = data.fetch(:token, nil)
145
+ @card = data.fetch(:card, nil)
146
+ @name = data.fetch(:name, "")
147
+ @authorized_amount = data.fetch(:authorized_amount, "")
148
+ @captured_amount = data.fetch(:captured_amount, "")
149
+ @currency = data.fetch(:currency, "")
150
+ @status = data.fetch(:status, "")
151
+ @authorized = data.fetch(:authorized, false)
152
+ @captured = data.fetch(:captured, false)
153
+ @processout_fee = data.fetch(:processout_fee, "")
154
+ @metadata = data.fetch(:metadata, Hash.new)
155
+ @sandbox = data.fetch(:sandbox, false)
156
+ @created_at = data.fetch(:created_at, "")
156
157
 
157
158
  end
158
159
 
160
+ # Create a new Transaction using the current client
161
+ def new(data = {})
162
+ Transaction.new(@client, data)
163
+ end
164
+
159
165
  # Fills the object with data coming from the API
160
166
  # Params:
161
167
  # +data+:: +Hash+ of data coming from the API
@@ -218,7 +224,7 @@ module ProcessOut
218
224
  # Get the transaction's refunds.
219
225
  # Params:
220
226
  # +options+:: +Hash+ of options
221
- def refunds(options = nil)
227
+ def refunds(options = {})
222
228
  request = Request.new(@client)
223
229
  path = "/transactions/" + CGI.escape(@id) + "/refunds"
224
230
  data = {
@@ -231,7 +237,7 @@ module ProcessOut
231
237
  a = Array.new
232
238
  body = response.body
233
239
  for v in body['refunds']
234
- tmp = Refund(@client)
240
+ tmp = Refund.new(@client)
235
241
  tmp.fill_with_data(v)
236
242
  a.push(tmp)
237
243
  end
@@ -246,7 +252,7 @@ module ProcessOut
246
252
  # Get all the transactions.
247
253
  # Params:
248
254
  # +options+:: +Hash+ of options
249
- def all(options = nil)
255
+ def all(options = {})
250
256
  request = Request.new(@client)
251
257
  path = "/transactions"
252
258
  data = {
@@ -259,7 +265,7 @@ module ProcessOut
259
265
  a = Array.new
260
266
  body = response.body
261
267
  for v in body['transactions']
262
- tmp = Transaction(@client)
268
+ tmp = Transaction.new(@client)
263
269
  tmp.fill_with_data(v)
264
270
  a.push(tmp)
265
271
  end
@@ -275,7 +281,7 @@ module ProcessOut
275
281
  # Params:
276
282
  # +transaction_id+:: ID of the transaction
277
283
  # +options+:: +Hash+ of options
278
- def find(transaction_id, options = nil)
284
+ def find(transaction_id, options = {})
279
285
  request = Request.new(@client)
280
286
  path = "/transactions/" + CGI.escape(transaction_id) + ""
281
287
  data = {
@@ -1,3 +1,3 @@
1
1
  module ProcessOut
2
- VERSION = "0.2.1"
2
+ VERSION = "0.3.0"
3
3
  end
@@ -87,24 +87,30 @@ module ProcessOut
87
87
  # Initializes the Webhook object
88
88
  # Params:
89
89
  # +client+:: +ProcessOut+ client instance
90
- def initialize(client)
90
+ # +data+:: data that can be used to fill the object
91
+ def initialize(client, data = {})
91
92
  @client = client
92
93
 
93
- @id = ""
94
- @project = nil
95
- @event = nil
96
- @request_url = ""
97
- @request_method = ""
98
- @response_body = ""
99
- @response_code = ""
100
- @response_headers = ""
101
- @response_time_ms = 0
102
- @status = 0
103
- @created_at = ""
104
- @release_at = ""
94
+ @id = data.fetch(:id, "")
95
+ @project = data.fetch(:project, nil)
96
+ @event = data.fetch(:event, nil)
97
+ @request_url = data.fetch(:request_url, "")
98
+ @request_method = data.fetch(:request_method, "")
99
+ @response_body = data.fetch(:response_body, "")
100
+ @response_code = data.fetch(:response_code, "")
101
+ @response_headers = data.fetch(:response_headers, "")
102
+ @response_time_ms = data.fetch(:response_time_ms, 0)
103
+ @status = data.fetch(:status, 0)
104
+ @created_at = data.fetch(:created_at, "")
105
+ @release_at = data.fetch(:release_at, "")
105
106
 
106
107
  end
107
108
 
109
+ # Create a new Webhook using the current client
110
+ def new(data = {})
111
+ Webhook.new(@client, data)
112
+ end
113
+
108
114
  # Fills the object with data coming from the API
109
115
  # Params:
110
116
  # +data+:: +Hash+ of data coming from the API
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: processout
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Manuel HUEZ
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-11-14 00:00:00.000000000 Z
11
+ date: 2016-11-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler