slidepay 0.0.4 → 0.0.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.
- checksums.yaml +4 -4
- data/lib/slidepay.rb +3 -0
- data/lib/slidepay/resources/api_key.rb +3 -0
- data/lib/slidepay/resources/api_resource.rb +23 -0
- data/lib/slidepay/resources/company.rb +14 -0
- data/lib/slidepay/resources/location.rb +14 -0
- data/lib/slidepay/resources/user_master.rb +13 -0
- data/lib/slidepay/version.rb +1 -1
- data/scenarios/company_retrieve.rb +19 -0
- data/scenarios/example.rb +7 -8
- data/scenarios/location_retrieve.rb +19 -0
- data/scenarios/user_master_find_with_first_name_fragment.rb +29 -0
- data/spec/api_resource_spec.rb +29 -0
- metadata +8 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6f02a6a0033d97c8e58e010e55bb11c3cce8bfae
|
4
|
+
data.tar.gz: 310224996914ac9859979addc22cb12ac10db09a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dcd535a7b5947ca00dd800e31eec00e75b9b9782ee03761f8a589fd61519d39a472bd599ad6b853dff53a872c59507dd41ee4e22d6b6cd779bbfefba898ff7e4
|
7
|
+
data.tar.gz: ad170f2b29a6290fa6ce503aadc26a5c31fa71be71dbd372751c404236701f44678721eead60e4486a98ace8063a49b4db5f9dc940cf93fa3bec9c80fea0ee75
|
data/lib/slidepay.rb
CHANGED
@@ -15,7 +15,10 @@ require "slidepay/client"
|
|
15
15
|
require "slidepay/resources/api_resource"
|
16
16
|
require "slidepay/resources/api_key"
|
17
17
|
require "slidepay/resources/payment"
|
18
|
+
require "slidepay/resources/user_master"
|
18
19
|
require "slidepay/resources/bank_account"
|
20
|
+
require "slidepay/resources/company"
|
21
|
+
require "slidepay/resources/location"
|
19
22
|
|
20
23
|
module SlidePay
|
21
24
|
class << self
|
@@ -119,6 +119,29 @@ module SlidePay
|
|
119
119
|
end
|
120
120
|
|
121
121
|
class << self
|
122
|
+
|
123
|
+
def find(search_params, token=nil, api_key=nil, endpoint=nil)
|
124
|
+
# Make sure the search parameters are valid
|
125
|
+
# raise Exception.new("Invalid search filter supplied.") unless validate_search_filters(search_params)
|
126
|
+
|
127
|
+
if search_params.is_a? Hash
|
128
|
+
search_params = [search_params]
|
129
|
+
elsif not search_params.is_a? Array
|
130
|
+
raise Exception.new("Invalid or no search filter supplied.")
|
131
|
+
end
|
132
|
+
|
133
|
+
search_results = []
|
134
|
+
response = SlidePay.put(path: self::URL_ROOT, data: search_params.to_json, token: token, api_key: api_key, endpoint: endpoint)
|
135
|
+
if response.was_successful? and response.data != nil
|
136
|
+
data = response.data
|
137
|
+
data.each do |resource_hash|
|
138
|
+
search_results.push self.new(resource_hash)
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
142
|
+
search_results
|
143
|
+
end
|
144
|
+
|
122
145
|
def find_where(search_params, token=nil, api_key=nil, endpoint=nil)
|
123
146
|
sfa = []
|
124
147
|
search_params.each_pair do |k,v|
|
data/lib/slidepay/version.rb
CHANGED
@@ -0,0 +1,19 @@
|
|
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}"
|
data/scenarios/example.rb
CHANGED
@@ -12,14 +12,8 @@ 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
|
-
|
21
15
|
p = Payment.new
|
22
|
-
p["amount"] =
|
16
|
+
p["amount"] = 2.01
|
23
17
|
p["method"] = "CreditCard"
|
24
18
|
p["cc_number"] = "4111111111111111"
|
25
19
|
p["cc_cvv2"] = "111"
|
@@ -27,6 +21,11 @@ p["cc_billing_zip"] = "11111"
|
|
27
21
|
p["cc_expiry_month"] = "10"
|
28
22
|
p["cc_expiry_year"] = "14"
|
29
23
|
r = p.process()
|
30
|
-
p.refund()
|
24
|
+
# p.refund()
|
31
25
|
|
26
|
+
p2 = Payment.new
|
27
|
+
p2['payment_id'] = p.id
|
32
28
|
|
29
|
+
p2.retrieve()
|
30
|
+
p2['under_review'] = 1
|
31
|
+
p2.save()
|
@@ -0,0 +1,19 @@
|
|
1
|
+
$:.unshift(File.join(File.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
|
+
l = Location.new
|
16
|
+
l['location_id'] = ENV["location_id"]
|
17
|
+
l.retrieve()
|
18
|
+
|
19
|
+
puts "Location: #{l}"
|
@@ -0,0 +1,29 @@
|
|
1
|
+
$:.unshift(File.join(File.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
|
+
|
16
|
+
puts "Finding UserMaster objects where first_name 'contains' 'at':"
|
17
|
+
puts "======================================================================"
|
18
|
+
|
19
|
+
users = UserMaster.find(field: "first_name", condition: "contains", value: "at")
|
20
|
+
if users.is_a? Array
|
21
|
+
puts "Retrieved an array of #{users.length} users"
|
22
|
+
|
23
|
+
users.each do |user|
|
24
|
+
puts "User found: #{user}"
|
25
|
+
end
|
26
|
+
|
27
|
+
else
|
28
|
+
puts "Did not get an array back!! Retrieved: #{users}"
|
29
|
+
end
|
data/spec/api_resource_spec.rb
CHANGED
@@ -233,12 +233,41 @@ describe SlidePay::ApiResource do
|
|
233
233
|
it "should be represented by several instance methods" do
|
234
234
|
public_methods = SlidePay::ApiResource.public_methods
|
235
235
|
|
236
|
+
expect(public_methods.include?(:find)).to be_true
|
236
237
|
expect(public_methods.include?(:find_where)).to be_true
|
237
238
|
expect(public_methods.include?(:find_greater_than)).to be_true
|
238
239
|
expect(public_methods.include?(:find_less_than)).to be_true
|
239
240
|
expect(public_methods.include?(:find_between)).to be_true
|
240
241
|
end
|
241
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
|
251
|
+
|
252
|
+
it "should accept a hash" do
|
253
|
+
expect { SlidePay::ApiResource.find(field: "name", condition: "contains", value: "doug") }.not_to raise_error
|
254
|
+
end
|
255
|
+
|
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
|
259
|
+
end
|
260
|
+
|
261
|
+
it "should return an array of resources" do
|
262
|
+
expect(SlidePay::ApiResource.find(field: "name", condition: "contains", value: "doug")).to be_a(Array)
|
263
|
+
end
|
264
|
+
|
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")
|
268
|
+
end
|
269
|
+
end
|
270
|
+
|
242
271
|
describe "find_where" do
|
243
272
|
it "should raise an error if no parameters are supplied" do
|
244
273
|
expect{ SlidePay::ApiResource.find_where }.to raise_error
|
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.5
|
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
|
+
date: 2013-11-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|
@@ -160,13 +160,19 @@ 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
|
163
165
|
- lib/slidepay/resources/payment.rb
|
166
|
+
- lib/slidepay/resources/user_master.rb
|
164
167
|
- lib/slidepay/response.rb
|
165
168
|
- lib/slidepay/util.rb
|
166
169
|
- lib/slidepay/version.rb
|
170
|
+
- scenarios/company_retrieve.rb
|
167
171
|
- scenarios/example.rb
|
172
|
+
- scenarios/location_retrieve.rb
|
168
173
|
- scenarios/payment_find_where_id.rb
|
169
174
|
- scenarios/payment_find_where_under_review.rb
|
175
|
+
- scenarios/user_master_find_with_first_name_fragment.rb
|
170
176
|
- slidepay.gemspec
|
171
177
|
- spec/api_key_spec.rb
|
172
178
|
- spec/api_resource_spec.rb
|