conekta 0.3.3 → 0.3.5

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.
Files changed (68) hide show
  1. checksums.yaml +8 -8
  2. data/.gitignore +5 -11
  3. data/CHANGELOG +5 -0
  4. data/Gemfile +6 -1
  5. data/LICENSE.txt +22 -0
  6. data/README.md +59 -0
  7. data/Rakefile +1 -14
  8. data/conekta.gemspec +22 -22
  9. data/lib/conekta.rb +36 -290
  10. data/lib/conekta/card.rb +10 -34
  11. data/lib/conekta/charge.rb +14 -38
  12. data/lib/conekta/conekta_object.rb +64 -136
  13. data/lib/conekta/customer.rb +23 -25
  14. data/lib/conekta/error.rb +65 -0
  15. data/lib/conekta/event.rb +2 -2
  16. data/lib/conekta/operations/create.rb +19 -0
  17. data/lib/conekta/operations/create_member.rb +30 -0
  18. data/lib/conekta/operations/custom_action.rb +17 -0
  19. data/lib/conekta/operations/delete.rb +43 -0
  20. data/lib/conekta/operations/find.rb +28 -0
  21. data/lib/conekta/operations/update.rb +13 -0
  22. data/lib/conekta/operations/where.rb +28 -0
  23. data/lib/conekta/payment_method.rb +4 -0
  24. data/lib/conekta/plan.rb +8 -5
  25. data/lib/conekta/requestor.rb +55 -0
  26. data/lib/conekta/resource.rb +13 -0
  27. data/lib/conekta/subscription.rb +12 -26
  28. data/lib/conekta/token.rb +3 -2
  29. data/lib/conekta/util.rb +19 -91
  30. data/lib/conekta/version.rb +1 -1
  31. data/lib/ssl_data/ca_bundle.crt +66 -0
  32. data/spec/conekta_spec.rb +299 -808
  33. data/spec/spec_helper.rb +12 -0
  34. metadata +55 -72
  35. data/CONTRIBUTORS +0 -9
  36. data/Gemfile.lock +0 -57
  37. data/History.txt +0 -4
  38. data/LICENSE +0 -23
  39. data/README.rdoc +0 -30
  40. data/VERSION +0 -1
  41. data/bin/conekta-console +0 -7
  42. data/bin/test calls +0 -205
  43. data/gemfiles/default-with-activesupport.gemfile +0 -3
  44. data/gemfiles/json.gemfile +0 -4
  45. data/gemfiles/yajl.gemfile +0 -4
  46. data/lib/conekta/account.rb +0 -4
  47. data/lib/conekta/api_operations/create.rb +0 -16
  48. data/lib/conekta/api_operations/create_member.rb +0 -18
  49. data/lib/conekta/api_operations/delete.rb +0 -11
  50. data/lib/conekta/api_operations/list.rb +0 -16
  51. data/lib/conekta/api_operations/modify_member.rb +0 -12
  52. data/lib/conekta/api_operations/update.rb +0 -22
  53. data/lib/conekta/api_resource.rb +0 -33
  54. data/lib/conekta/errors/api_connection_error.rb +0 -4
  55. data/lib/conekta/errors/api_error.rb +0 -4
  56. data/lib/conekta/errors/authentication_error.rb +0 -4
  57. data/lib/conekta/errors/card_error.rb +0 -11
  58. data/lib/conekta/errors/conekta_error.rb +0 -20
  59. data/lib/conekta/errors/malformed_request_error.rb +0 -10
  60. data/lib/conekta/errors/parameter_validation_error.rb +0 -10
  61. data/lib/conekta/errors/resource_not_found_error.rb +0 -10
  62. data/lib/conekta/json.rb +0 -21
  63. data/lib/conekta/list_object.rb +0 -35
  64. data/lib/conekta/log.rb +0 -5
  65. data/lib/conekta/singleton_api_resource.rb +0 -20
  66. data/lib/data/ca-certificates.crt +0 -3918
  67. data/spec/conekta_with_active_support_spec.rb +0 -3
  68. data/spec/test_helper.rb +0 -338
@@ -1,3 +0,0 @@
1
- require 'rubygems'
2
- require 'active_support/all'
3
- load File.expand_path(File.join(File.dirname(__FILE__), 'conekta_spec.rb'))
data/spec/test_helper.rb DELETED
@@ -1,338 +0,0 @@
1
- require 'stringio'
2
- require 'test/unit'
3
- require 'conekta'
4
- require 'mocha/setup'
5
- include Mocha
6
-
7
- #monkeypatch request methods
8
- module Conekta
9
- @mock_rest_client = nil
10
-
11
- def self.mock_rest_client=(mock_client)
12
- @mock_rest_client = mock_client
13
- end
14
-
15
- def self.execute_request(opts)
16
- get_params = (opts[:headers] || {})[:params]
17
- post_params = opts[:payload]
18
- case opts[:method]
19
- when :get then @mock_rest_client.get opts[:url], get_params, post_params
20
- when :post then @mock_rest_client.post opts[:url], get_params, post_params
21
- when :delete then @mock_rest_client.delete opts[:url], get_params, post_params
22
- end
23
- end
24
- end
25
-
26
- def test_response(body, code=200)
27
- # When an exception is raised, restclient clobbers method_missing. Hence we
28
- # can't just use the stubs interface.
29
- body = MultiJson.dump(body) if !(body.kind_of? String)
30
- m = double
31
- m.instance_variable_set('@conekta_values', { :body => body, :code => code })
32
- def m.body; @conekta_values[:body]; end
33
- def m.code; @conekta_values[:code]; end
34
- m
35
- end
36
-
37
- def test_plan(params={})
38
- {
39
- :id => "gold-plan",
40
- :name => "Gold Plan",
41
- :amount => 10000,
42
- :frequency => "month",
43
- :trial_period_days => 15,
44
- :object => "plan",
45
- :expiry_count => 12
46
- }
47
- end
48
-
49
- def test_token(params={})
50
- {
51
- :livemode => false,
52
- :used => false,
53
- :object => "token",
54
- :id => "c_test_token",
55
- :created => 1304114758,
56
- :card => test_token_card
57
- }.merge(params)
58
- end
59
-
60
- def test_customer(params={})
61
- {
62
- :subscription_history => [],
63
- :bills => [],
64
- :charges => [],
65
- :livemode => false,
66
- :object => "customer",
67
- :id => "c_test_customer",
68
- :default_card => "cc_test_card",
69
- :created => 1304114758,
70
- :cards => test_card_array('c_test_customer')
71
- }.merge(params)
72
- end
73
-
74
- def test_customer_array
75
- {
76
- :data => [test_customer, test_customer, test_customer],
77
- :object => 'list',
78
- :url => '/customers'
79
- }
80
- end
81
-
82
- def test_charge(params={})
83
- {
84
- :refunded => false,
85
- :paid => true,
86
- :amount => 100,
87
- :card => {
88
- :type => "Visa",
89
- :last4 => "4242",
90
- :exp_month => 11,
91
- :country => "US",
92
- :exp_year => 2012,
93
- :id => "cc_test_card",
94
- :object => "card"
95
- },
96
- :id => "ch_test_charge",
97
- :reason => "execute_charge",
98
- :livemode => false,
99
- :currency => "usd",
100
- :object => "charge",
101
- :created => 1304114826
102
- }.merge(params)
103
- end
104
-
105
- def test_charge_array_filtered
106
- {
107
- :data => [test_charge, test_charge, test_charge],
108
- :object => 'list',
109
- :url => '/charges.json?amount=500'
110
- }
111
- end
112
-
113
- def test_charge_array
114
- {
115
- :data => [test_charge, test_charge, test_charge],
116
- :object => 'list',
117
- :url => '/charges'
118
- }
119
- end
120
-
121
- def test_card_array(customer_id)
122
- {
123
- :data => [test_card, test_card, test_card],
124
- :object => 'list',
125
- :url => '/customers/' + customer_id + '/cards'
126
- }
127
- end
128
-
129
- def test_token_card(params={})
130
- {
131
- :type => "Visa",
132
- :last4 => "4242",
133
- :exp_month => 11,
134
- :country => "US",
135
- :exp_year => 2012,
136
- :id => "cc_test_card",
137
- :customer => 'c_test_token',
138
- :object => "card"
139
- }.merge(params)
140
- end
141
-
142
- def test_card(params={})
143
- {
144
- :type => "Visa",
145
- :last4 => "4242",
146
- :exp_month => 11,
147
- :country => "US",
148
- :exp_year => 2012,
149
- :id => "cc_test_card",
150
- :customer => 'c_test_customer',
151
- :object => "card"
152
- }.merge(params)
153
- end
154
-
155
- def test_coupon(params={})
156
- {
157
- :duration => 'repeating',
158
- :duration_in_months => 3,
159
- :percent_off => 25,
160
- :id => "co_test_coupon",
161
- :object => "coupon"
162
- }.merge(params)
163
- end
164
-
165
- #FIXME nested overrides would be better than hardcoding plan_id
166
- def test_subscription(plan_id="gold")
167
- {
168
- :current_period_end => 1308681468,
169
- :status => "trialing",
170
- :plan => {
171
- :interval => "month",
172
- :amount => 7500,
173
- :trial_period_days => 30,
174
- :object => "plan",
175
- :identifier => plan_id
176
- },
177
- :current_period_start => 1308595038,
178
- :start => 1308595038,
179
- :object => "subscription",
180
- :trial_start => 1308595038,
181
- :trial_end => 1308681468,
182
- :customer => "c_test_customer"
183
- }
184
- end
185
-
186
- def test_invoice
187
- {
188
- :id => 'in_test_invoice',
189
- :object => 'invoice',
190
- :livemode => false,
191
- :amount_due => 1000,
192
- :attempt_count => 0,
193
- :attempted => false,
194
- :closed => false,
195
- :currency => 'usd',
196
- :customer => 'c_test_customer',
197
- :date => 1349738950,
198
- :lines => {
199
- "invoiceitems" => [
200
- {
201
- :id => 'ii_test_invoice_item',
202
- :object => '',
203
- :livemode => false,
204
- :amount => 1000,
205
- :currency => 'usd',
206
- :customer => 'c_test_customer',
207
- :date => 1349738950,
208
- :description => "A Test Invoice Item",
209
- :invoice => 'in_test_invoice'
210
- },
211
- ],
212
- },
213
- :paid => false,
214
- :period_end => 1349738950,
215
- :period_start => 1349738950,
216
- :starting_balance => 0,
217
- :subtotal => 1000,
218
- :total => 1000,
219
- :charge => nil,
220
- :discount => nil,
221
- :ending_balance => nil,
222
- :next_payemnt_attempt => 1349825350,
223
- }
224
- end
225
-
226
- def test_paid_invoice
227
- test_invoice.merge({
228
- :attempt_count => 1,
229
- :attempted => true,
230
- :closed => true,
231
- :paid => true,
232
- :charge => 'ch_test_charge',
233
- :ending_balance => 0,
234
- :next_payment_attempt => nil,
235
- })
236
- end
237
-
238
- def test_invoice_customer_array
239
- {
240
- :data => [test_invoice],
241
- :object => 'list',
242
- :url => '/invoices?customer=test_customer'
243
- }
244
- end
245
-
246
- def test_recipient(params={})
247
- {
248
- :name => "Conekta User",
249
- :type => "individual",
250
- :livemode => false,
251
- :object => "recipient",
252
- :id => "rp_test_recipient",
253
- :active_account => {
254
- :last4 => "6789",
255
- :bank_name => "STRIPE TEST BANK",
256
- :country => "US",
257
- :object => "bank_account"
258
- },
259
- :created => 1304114758,
260
- :verified => true
261
- }.merge(params)
262
- end
263
-
264
- def test_recipient_array
265
- {
266
- :data => [test_recipient, test_recipient, test_recipient],
267
- :object => 'list',
268
- :url => '/recipients'
269
- }
270
- end
271
-
272
- def test_transfer(params={})
273
- {
274
- :status => 'pending',
275
- :amount => 100,
276
- :account => {
277
- :object => 'bank_account',
278
- :country => 'US',
279
- :bank_name => 'STRIPE TEST BANK',
280
- :last4 => '6789'
281
- },
282
- :recipient => 'test_recipient',
283
- :fee => 0,
284
- :fee_details => [],
285
- :id => "tr_test_transfer",
286
- :livemode => false,
287
- :currency => "usd",
288
- :object => "transfer",
289
- :date => 1304114826
290
- }.merge(params)
291
- end
292
-
293
- def test_transfer_array
294
- {
295
- :data => [test_transfer, test_transfer, test_transfer],
296
- :object => 'list',
297
- :url => '/transfers'
298
- }
299
- end
300
-
301
- def test_invalid_api_key_error
302
- {
303
- "error" => {
304
- "type" => "invalid_request_error",
305
- "message" => "Invalid API Key provided: invalid"
306
- }
307
- }
308
- end
309
-
310
- def test_invalid_exp_year_error
311
- {
312
- "code" => "invalid_expiry_year",
313
- "param" => "exp_year",
314
- "type" => "card_error",
315
- "message" => "Your card's expiration year is invalid"
316
- }
317
- end
318
-
319
- def test_missing_id_error
320
- {
321
- :param => "id",
322
- :type => "parameter_validation_error",
323
- :message => "Invalid id value"
324
- }
325
- end
326
-
327
- def test_api_error
328
- {
329
- :type => "api_error"
330
- }
331
- end
332
-
333
- def test_delete_discount_response
334
- {
335
- :deleted => true,
336
- :id => "di_test_coupon"
337
- }
338
- end