slidepay 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/lib/slidepay.rb +0 -2
- data/lib/slidepay/client.rb +6 -9
- data/lib/slidepay/resources/api_key.rb +0 -3
- data/lib/slidepay/resources/api_resource.rb +12 -0
- data/lib/slidepay/version.rb +1 -1
- data/scenarios/example.rb +8 -7
- data/scenarios/{location_retrieve.rb → user_master_retrieve.rb} +5 -4
- data/spec/api_resource_spec.rb +108 -89
- metadata +3 -6
- data/lib/slidepay/resources/company.rb +0 -14
- data/lib/slidepay/resources/location.rb +0 -14
- data/scenarios/company_retrieve.rb +0 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cd62eeffb82c24dd9a5b13c668a23360ef24518c
|
4
|
+
data.tar.gz: f923dc072e19a532cfa02fbc895624f0875ee314
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
[![
|
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,
|
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
|
data/lib/slidepay/client.rb
CHANGED
@@ -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
|
-
|
44
|
+
SlidePay.get(path: request_params, api_key: @api_key, token: @token, endpoint: @endpoint)
|
46
45
|
else
|
47
|
-
|
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
|
-
|
63
|
+
SlidePay.delete(path: request_params, api_key: @api_key, token: @token, endpoint: @endpoint)
|
67
64
|
else
|
68
|
-
|
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
|
|
@@ -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
|
data/lib/slidepay/version.rb
CHANGED
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"] =
|
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
|
-
|
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 "
|
16
|
+
puts "Retrieving users. "
|
17
|
+
users = SlidePay::UserMaster.retrieve()
|
18
|
+
|
19
|
+
puts "Done. #{users.length} users retrieved."
|
20
|
+
|
data/spec/api_resource_spec.rb
CHANGED
@@ -225,126 +225,145 @@ describe SlidePay::ApiResource do
|
|
225
225
|
end
|
226
226
|
end
|
227
227
|
|
228
|
-
describe "
|
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
|
-
|
253
|
-
|
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
|
257
|
-
|
258
|
-
expect
|
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
|
262
|
-
|
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
|
266
|
-
SlidePay.
|
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 "
|
272
|
-
|
273
|
-
|
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
|
277
|
-
|
278
|
-
end
|
255
|
+
it "should be represented by several instance methods" do
|
256
|
+
public_methods = SlidePay::ApiResource.public_methods
|
279
257
|
|
280
|
-
|
281
|
-
expect(
|
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
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
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
|
-
|
291
|
-
|
292
|
-
|
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
|
-
|
296
|
-
|
297
|
-
|
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
|
-
|
300
|
-
|
301
|
-
|
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
|
-
|
304
|
-
|
305
|
-
|
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
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
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
|
-
|
315
|
-
|
316
|
-
|
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
|
-
|
319
|
-
|
320
|
-
|
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
|
-
|
323
|
-
|
324
|
-
|
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
|
-
|
329
|
-
|
330
|
-
|
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
|
-
|
334
|
-
|
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
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
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
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
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.
|
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-
|
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,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}"
|