slidepay 0.0.5 → 0.0.6

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6f02a6a0033d97c8e58e010e55bb11c3cce8bfae
4
- data.tar.gz: 310224996914ac9859979addc22cb12ac10db09a
3
+ metadata.gz: cd62eeffb82c24dd9a5b13c668a23360ef24518c
4
+ data.tar.gz: f923dc072e19a532cfa02fbc895624f0875ee314
5
5
  SHA512:
6
- metadata.gz: dcd535a7b5947ca00dd800e31eec00e75b9b9782ee03761f8a589fd61519d39a472bd599ad6b853dff53a872c59507dd41ee4e22d6b6cd779bbfefba898ff7e4
7
- data.tar.gz: ad170f2b29a6290fa6ce503aadc26a5c31fa71be71dbd372751c404236701f44678721eead60e4486a98ace8063a49b4db5f9dc940cf93fa3bec9c80fea0ee75
6
+ metadata.gz: fc7c0e792d1345f7a27386e6cf723a1fc14beb1913a7a59da43ae07dfaace5f21b51a61a0ae9926ac58b287cba041de1816c1c88d363dfc13769170ac8f9b26b
7
+ data.tar.gz: 1d853ef6581545a605a0b31f861b2001fa05599e108d296216ef889f306767e5b78a48773f1964cc775c95836614b4af5adaddc32b92e85bd516dd536628f0e9
data/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  # Slidepay Ruby Sdk
4
4
 
5
- [![Gem Version](https://badge.fury.io/rb/slidepay.png)](http://badge.fury.io/rb/slidepay) [![Build Status](https://travis-ci.org/SlidePay/slidepay-ruby-sdk.png)](https://travis-ci.org/SlidePay/slidepay-ruby-sdk) [![Code Climate](https://codeclimate.com/repos/5236cb7013d6371e46004010/badges/f963bebb1565c5419c78/gpa.png)](https://codeclimate.com/repos/5236cb7013d6371e46004010/feed)
5
+ [![Build Status](https://travis-ci.org/SlidePay/slidepay-ruby-sdk.png)](https://travis-ci.org/SlidePay/slidepay-ruby-sdk) [![Code Climate](https://codeclimate.com/repos/5236cb7013d6371e46004010/badges/f963bebb1565c5419c78/gpa.png)](https://codeclimate.com/repos/5236cb7013d6371e46004010/feed)
6
6
 
7
7
  First version of the SlidePay Ruby SDK
8
8
 
@@ -31,7 +31,7 @@ Check out our [main documentation](https://getcube.atlassian.net/wiki/display/CD
31
31
  Requests can be made three ways:
32
32
 
33
33
  1. Using the SlidePay request methods directly with the desired API url and relevant request JSON
34
- 2. Using an instance of the SlidePay::Client class to save an ApiResource, such as a payment, bank_account, or api_key
34
+ 2. [Coming Soon] Using an instance of the SlidePay::Client class to save an ApiResource, such as a payment, order, or item
35
35
  3. Using an instance of a SlidePay::ApiResource class, such as SlidePay::ApiKey or SlidePay::Payment
36
36
 
37
37
  ## Authentication
data/lib/slidepay.rb CHANGED
@@ -17,8 +17,6 @@ require "slidepay/resources/api_key"
17
17
  require "slidepay/resources/payment"
18
18
  require "slidepay/resources/user_master"
19
19
  require "slidepay/resources/bank_account"
20
- require "slidepay/resources/company"
21
- require "slidepay/resources/location"
22
20
 
23
21
  module SlidePay
24
22
  class << self
@@ -40,14 +40,12 @@ module SlidePay
40
40
 
41
41
  # Base Request Methods
42
42
  def get(request_params)
43
- options = {}
44
43
  if request_params.is_a? String
45
- options = { :path => request_params, :api_key => @api_key, :token => @token, :endpoint => @endpoint }
44
+ SlidePay.get(path: request_params, api_key: @api_key, token: @token, endpoint: @endpoint)
46
45
  else
47
- options = request_params.merge! api_key: @api_key, token: @token, endpoint: @endpoint
46
+ request_params.merge! api_key: @api_key, token: @token, endpoint: @endpoint
47
+ SlidePay.get(request_params)
48
48
  end
49
-
50
- SlidePay.get(options)
51
49
  end
52
50
 
53
51
  def put(request_params)
@@ -61,13 +59,12 @@ module SlidePay
61
59
  end
62
60
 
63
61
  def delete(request_params)
64
- options = {}
65
62
  if request_params.is_a? String
66
- options = { :path => request_params, :api_key => @api_key, :token => @token, :endpoint => @endpoint }
63
+ SlidePay.delete(path: request_params, api_key: @api_key, token: @token, endpoint: @endpoint)
67
64
  else
68
- options = request_params.merge! api_key: @api_key, token: @token, endpoint: @endpoint
65
+ request_params.merge! api_key: @api_key, token: @token, endpoint: @endpoint
66
+ SlidePay.delete(request_params)
69
67
  end
70
- SlidePay.delete(options)
71
68
  end
72
69
 
73
70
 
@@ -1,8 +1,5 @@
1
1
  module SlidePay
2
2
  class ApiKey < ApiResource
3
- URL_ROOT = "api_key"
4
- ID_ATTRIBUTE = "api_key_id"
5
-
6
3
  def initialize(values_hash={})
7
4
  @url_root = "api_key"
8
5
  @id_attribute = "api_key_id"
@@ -119,6 +119,18 @@ module SlidePay
119
119
  end
120
120
 
121
121
  class << self
122
+ def retrieve(token=nil, api_key=nil, endpoint=nil)
123
+ response = SlidePay.get(path: self::URL_ROOT, token: token, api_key: api_key, endpoint: endpoint)
124
+
125
+ results = []
126
+ if response.was_successful? and response.data != nil
127
+ data = response.data
128
+ data.each do |resource_hash|
129
+ results.push self.new(resource_hash)
130
+ end
131
+ end
132
+ results
133
+ end
122
134
 
123
135
  def find(search_params, token=nil, api_key=nil, endpoint=nil)
124
136
  # Make sure the search parameters are valid
@@ -1,3 +1,3 @@
1
1
  module SlidePay
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
data/scenarios/example.rb CHANGED
@@ -12,8 +12,14 @@ SlidePay.api_key = ENV["api_key"]
12
12
 
13
13
  # RestClient.proxy = "http://127.0.0.1:8888"
14
14
 
15
+ # a = ApiKey.new
16
+ # a["api_key_id"] = 17
17
+ # a.is_new?
18
+ # a.id_attribute
19
+ # a.retrieve()
20
+
15
21
  p = Payment.new
16
- p["amount"] = 2.01
22
+ p["amount"] = 1.01
17
23
  p["method"] = "CreditCard"
18
24
  p["cc_number"] = "4111111111111111"
19
25
  p["cc_cvv2"] = "111"
@@ -21,11 +27,6 @@ p["cc_billing_zip"] = "11111"
21
27
  p["cc_expiry_month"] = "10"
22
28
  p["cc_expiry_year"] = "14"
23
29
  r = p.process()
24
- # p.refund()
30
+ p.refund()
25
31
 
26
- p2 = Payment.new
27
- p2['payment_id'] = p.id
28
32
 
29
- p2.retrieve()
30
- p2['under_review'] = 1
31
- p2.save()
@@ -12,8 +12,9 @@ SlidePay.api_key = ENV["api_key"]
12
12
 
13
13
  RestClient.proxy = "http://127.0.0.1:8888"
14
14
 
15
- l = Location.new
16
- l['location_id'] = ENV["location_id"]
17
- l.retrieve()
18
15
 
19
- puts "Location: #{l}"
16
+ puts "Retrieving users. "
17
+ users = SlidePay::UserMaster.retrieve()
18
+
19
+ puts "Done. #{users.length} users retrieved."
20
+
@@ -225,126 +225,145 @@ describe SlidePay::ApiResource do
225
225
  end
226
226
  end
227
227
 
228
- describe "search" do
229
- before(:all) do
230
- SlidePay.stub(:put) { a_response_object(successful_array_response) }
231
- end
232
-
233
- it "should be represented by several instance methods" do
234
- public_methods = SlidePay::ApiResource.public_methods
235
-
236
- expect(public_methods.include?(:find)).to be_true
237
- expect(public_methods.include?(:find_where)).to be_true
238
- expect(public_methods.include?(:find_greater_than)).to be_true
239
- expect(public_methods.include?(:find_less_than)).to be_true
240
- expect(public_methods.include?(:find_between)).to be_true
241
- end
242
-
243
- describe "find" do
244
- it "should raise an error if no parameters are supplied" do
245
- expect{ SlidePay::ApiResource.find }.to raise_error
246
- end
247
-
248
- # it "should raise an error if the parameters are not search filter arrays" do
249
- # expect{ SlidePay::ApiResource.find(name: "doug") }.to raise_error
250
- # end
228
+ describe "class methods" do
251
229
 
252
- it "should accept a hash" do
253
- expect { SlidePay::ApiResource.find(field: "name", condition: "contains", value: "doug") }.not_to raise_error
230
+ describe "retrieve" do
231
+ before(:all) do
232
+ SlidePay.stub(:get) { a_response_object(successful_array_response) }
254
233
  end
255
234
 
256
- it "should accept an array of hashes" do
257
- search_filter_array = [{field: "name", condition: "contains", value: "doug"}, {field: "created", condition: "greater_than", value: "10/01/2013"}]
258
- expect { SlidePay::ApiResource.find(search_filter_array) }.not_to raise_error
235
+ it "should have a retrieve method" do
236
+ public_methods = SlidePay::ApiResource.public_methods
237
+ expect(public_methods.include?(:retrieve)).to be_true
259
238
  end
260
239
 
261
- it "should return an array of resources" do
262
- expect(SlidePay::ApiResource.find(field: "name", condition: "contains", value: "doug")).to be_a(Array)
240
+ it "should make a get request" do
241
+ SlidePay.should_receive(:get).and_return(a_response_object(successful_array_response))
242
+ SlidePay::ApiResource.retrieve()
263
243
  end
264
244
 
265
- it "should make a put request" do
266
- SlidePay.should_receive(:put).and_return(a_response_object(successful_array_response))
267
- SlidePay::ApiResource.find(field: "name", condition: "contains", value: "doug")
245
+ it "should return an array of ApiResources" do
246
+ expect(SlidePay::ApiResource.retrieve()).to be_a(Array)
268
247
  end
269
248
  end
270
249
 
271
- describe "find_where" do
272
- it "should raise an error if no parameters are supplied" do
273
- expect{ SlidePay::ApiResource.find_where }.to raise_error
250
+ describe "search" do
251
+ before(:all) do
252
+ SlidePay.stub(:put) { a_response_object(successful_array_response) }
274
253
  end
275
254
 
276
- it "should accept a hash" do
277
- expect { SlidePay::ApiResource.find_where(created: "12/13/2013") }.not_to raise_error
278
- end
255
+ it "should be represented by several instance methods" do
256
+ public_methods = SlidePay::ApiResource.public_methods
279
257
 
280
- it "should return an array of resources" do
281
- expect(SlidePay::ApiResource.find_where(created: "12/13/2013")).to be_a(Array)
258
+ expect(public_methods.include?(:find)).to be_true
259
+ expect(public_methods.include?(:find_where)).to be_true
260
+ expect(public_methods.include?(:find_greater_than)).to be_true
261
+ expect(public_methods.include?(:find_less_than)).to be_true
262
+ expect(public_methods.include?(:find_between)).to be_true
282
263
  end
283
264
 
284
- it "should make a put request" do
285
- SlidePay.should_receive(:put).and_return(a_response_object(successful_array_response))
286
- SlidePay::ApiResource.find_where(created: "12/13/2013")
287
- end
288
- end
265
+ describe "find" do
266
+ it "should raise an error if no parameters are supplied" do
267
+ expect{ SlidePay::ApiResource.find }.to raise_error
268
+ end
289
269
 
290
- describe "find_greater_than" do
291
- it "should raise an error if no parameters are supplied" do
292
- expect{ SlidePay::ApiResource.find_greater_than }.to raise_error
293
- end
270
+ it "should accept a hash" do
271
+ expect { SlidePay::ApiResource.find(field: "name", condition: "contains", value: "doug") }.not_to raise_error
272
+ end
294
273
 
295
- it "should accept a hash" do
296
- expect { SlidePay::ApiResource.find_greater_than(created: "12/13/2013") }.not_to raise_error
297
- end
274
+ it "should accept an array of hashes" do
275
+ search_filter_array = [{field: "name", condition: "contains", value: "doug"}, {field: "created", condition: "greater_than", value: "10/01/2013"}]
276
+ expect { SlidePay::ApiResource.find(search_filter_array) }.not_to raise_error
277
+ end
298
278
 
299
- it "should return an array of resources" do
300
- expect(SlidePay::ApiResource.find_greater_than(created: "12/13/2013")).to be_a(Array)
301
- end
279
+ it "should return an array of resources" do
280
+ expect(SlidePay::ApiResource.find(field: "name", condition: "contains", value: "doug")).to be_a(Array)
281
+ end
302
282
 
303
- it "should make a put request" do
304
- SlidePay.should_receive(:put).and_return(a_response_object(successful_array_response))
305
- SlidePay::ApiResource.find_greater_than(created: "12/13/2013")
283
+ it "should make a put request" do
284
+ SlidePay.should_receive(:put).and_return(a_response_object(successful_array_response))
285
+ SlidePay::ApiResource.find(field: "name", condition: "contains", value: "doug")
286
+ end
306
287
  end
307
- end
308
288
 
309
- describe "find_less_than" do
310
- it "should raise an error if no parameters are supplied" do
311
- expect{ SlidePay::ApiResource.find_less_than }.to raise_error
312
- end
289
+ describe "find_where" do
290
+ it "should raise an error if no parameters are supplied" do
291
+ expect{ SlidePay::ApiResource.find_where }.to raise_error
292
+ end
313
293
 
314
- it "should accept a hash" do
315
- expect { SlidePay::ApiResource.find_less_than(created: "12/13/2013") }.not_to raise_error
316
- end
294
+ it "should accept a hash" do
295
+ expect { SlidePay::ApiResource.find_where(created: "12/13/2013") }.not_to raise_error
296
+ end
317
297
 
318
- it "should return an array of resources" do
319
- expect(SlidePay::ApiResource.find_less_than(created: "12/13/2013")).to be_a(Array)
320
- end
298
+ it "should return an array of resources" do
299
+ expect(SlidePay::ApiResource.find_where(created: "12/13/2013")).to be_a(Array)
300
+ end
321
301
 
322
- it "should make a put request" do
323
- SlidePay.should_receive(:put).and_return(a_response_object(successful_array_response))
324
- SlidePay::ApiResource.find_less_than(created: "12/13/2013")
302
+ it "should make a put request" do
303
+ SlidePay.should_receive(:put).and_return(a_response_object(successful_array_response))
304
+ SlidePay::ApiResource.find_where(created: "12/13/2013")
305
+ end
325
306
  end
326
- end
327
307
 
328
- describe "find_between" do
329
- it "should raise an error if no parameters are supplied" do
330
- expect{ SlidePay::ApiResource.find_between }.to raise_error
308
+ describe "find_greater_than" do
309
+ it "should raise an error if no parameters are supplied" do
310
+ expect{ SlidePay::ApiResource.find_greater_than }.to raise_error
311
+ end
312
+
313
+ it "should accept a hash" do
314
+ expect { SlidePay::ApiResource.find_greater_than(created: "12/13/2013") }.not_to raise_error
315
+ end
316
+
317
+ it "should return an array of resources" do
318
+ expect(SlidePay::ApiResource.find_greater_than(created: "12/13/2013")).to be_a(Array)
319
+ end
320
+
321
+ it "should make a put request" do
322
+ SlidePay.should_receive(:put).and_return(a_response_object(successful_array_response))
323
+ SlidePay::ApiResource.find_greater_than(created: "12/13/2013")
324
+ end
331
325
  end
332
326
 
333
- it "should return an array of resources" do
334
- SlidePay.should_receive(:put).and_return(a_response_object(successful_array_response))
327
+ describe "find_less_than" do
328
+ it "should raise an error if no parameters are supplied" do
329
+ expect{ SlidePay::ApiResource.find_less_than }.to raise_error
330
+ end
331
+
332
+ it "should accept a hash" do
333
+ expect { SlidePay::ApiResource.find_less_than(created: "12/13/2013") }.not_to raise_error
334
+ end
335
+
336
+ it "should return an array of resources" do
337
+ expect(SlidePay::ApiResource.find_less_than(created: "12/13/2013")).to be_a(Array)
338
+ end
335
339
 
336
- expect(SlidePay::ApiResource.find_between(
337
- { :created => "12/13/2013" },
338
- { :created => "12/14/2013" }
339
- )).to be_a(Array)
340
+ it "should make a put request" do
341
+ SlidePay.should_receive(:put).and_return(a_response_object(successful_array_response))
342
+ SlidePay::ApiResource.find_less_than(created: "12/13/2013")
343
+ end
340
344
  end
341
345
 
342
- it "should make a put request" do
343
- SlidePay.should_receive(:put).and_return(a_response_object(successful_array_response))
344
- expect(SlidePay::ApiResource.find_between(
345
- { :created => "12/13/2013" },
346
- { :created => "12/14/2013" }
347
- )).to be_a(Array)
346
+ describe "find_between" do
347
+ it "should raise an error if no parameters are supplied" do
348
+ expect{ SlidePay::ApiResource.find_between }.to raise_error
349
+ end
350
+
351
+ it "should return an array of resources" do
352
+ SlidePay.should_receive(:put).and_return(a_response_object(successful_array_response))
353
+
354
+ expect(SlidePay::ApiResource.find_between(
355
+ { :created => "12/13/2013" },
356
+ { :created => "12/14/2013" }
357
+ )).to be_a(Array)
358
+ end
359
+
360
+ it "should make a put request" do
361
+ SlidePay.should_receive(:put).and_return(a_response_object(successful_array_response))
362
+ expect(SlidePay::ApiResource.find_between(
363
+ { :created => "12/13/2013" },
364
+ { :created => "12/14/2013" }
365
+ )).to be_a(Array)
366
+ end
348
367
  end
349
368
  end
350
369
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: slidepay
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Rothstein
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-11-01 00:00:00.000000000 Z
11
+ date: 2013-11-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client
@@ -160,19 +160,16 @@ files:
160
160
  - lib/slidepay/resources/api_key.rb
161
161
  - lib/slidepay/resources/api_resource.rb
162
162
  - lib/slidepay/resources/bank_account.rb
163
- - lib/slidepay/resources/company.rb
164
- - lib/slidepay/resources/location.rb
165
163
  - lib/slidepay/resources/payment.rb
166
164
  - lib/slidepay/resources/user_master.rb
167
165
  - lib/slidepay/response.rb
168
166
  - lib/slidepay/util.rb
169
167
  - lib/slidepay/version.rb
170
- - scenarios/company_retrieve.rb
171
168
  - scenarios/example.rb
172
- - scenarios/location_retrieve.rb
173
169
  - scenarios/payment_find_where_id.rb
174
170
  - scenarios/payment_find_where_under_review.rb
175
171
  - scenarios/user_master_find_with_first_name_fragment.rb
172
+ - scenarios/user_master_retrieve.rb
176
173
  - slidepay.gemspec
177
174
  - spec/api_key_spec.rb
178
175
  - spec/api_resource_spec.rb
@@ -1,14 +0,0 @@
1
- module SlidePay
2
- class Company < ApiResource
3
- URL_ROOT = "company"
4
- ID_ATTRIBUTE = "company_id"
5
-
6
- def initialize(values_hash={})
7
- @url_root = "company"
8
- @id_attribute = "company_id"
9
-
10
- super(values_hash)
11
- end
12
-
13
- end
14
- end
@@ -1,14 +0,0 @@
1
- module SlidePay
2
- class Location < ApiResource
3
- URL_ROOT = "location"
4
- ID_ATTRIBUTE = "location_id"
5
-
6
- def initialize(values_hash={})
7
- @url_root = "location"
8
- @id_attribute = "location_id"
9
-
10
- super(values_hash)
11
- end
12
-
13
- end
14
- end
@@ -1,19 +0,0 @@
1
- $:.unshift(Fice.join(Fice.dirname(__FILE__), 'lib'))
2
- $:.unshift(File.join(File.dirname(__FILE__), 'spec'))
3
-
4
- require 'multi_json'
5
- require 'slidepay'
6
- require 'spec_helper'
7
-
8
- include SlidePay
9
-
10
- SlidePay.configure(development: true)
11
- SlidePay.api_key = ENV["api_key"]
12
-
13
- RestClient.proxy = "http://127.0.0.1:8888"
14
-
15
- c = Company.new
16
- c['company_id'] = ENV["company_id"]
17
- c.retrieve()
18
-
19
- puts "company: #{c}"