slidepay 0.0.9 → 0.0.10
Sign up to get free protection for your applications and to get access to all the features.
- 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 +4 -10
- data/lib/slidepay/resources/bank_account.rb +3 -0
- data/lib/slidepay/resources/company.rb +14 -0
- data/lib/slidepay/resources/customer.rb +4 -1
- data/lib/slidepay/resources/location.rb +14 -0
- data/lib/slidepay/resources/payment.rb +3 -3
- data/lib/slidepay/resources/user_master.rb +2 -2
- data/lib/slidepay/version.rb +1 -1
- data/scenarios/use_api_resource_for_arbitrary_object.rb +24 -0
- data/spec/payment_spec.rb +4 -3
- metadata +4 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f9b907bd0318a7474ca1e14f87e2f69dcd6c4641
|
4
|
+
data.tar.gz: 4441fdaabad3b64ac037d170b05ef6674d5c77e1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: beab9943102814e514e72881e334f39fe659b5fd6a2a97d49fce89208ecb4e5d2087fa62954496363b27d833eec4a7ef71ca02e786a6c1d7823cde1ddef473a5
|
7
|
+
data.tar.gz: 0ab42fd162f60a59b17776110dcd371de6d1aecfcc8284fb6c452003d3206078e5f54f05a8299c18a1393f118246377657170e756f5678c8531ccbacbf96a557
|
data/lib/slidepay.rb
CHANGED
@@ -17,6 +17,9 @@ 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/customer"
|
21
|
+
require "slidepay/resources/location"
|
22
|
+
require "slidepay/resources/company"
|
20
23
|
|
21
24
|
module SlidePay
|
22
25
|
class << self
|
@@ -2,10 +2,6 @@ module SlidePay
|
|
2
2
|
class ApiResource < Hash
|
3
3
|
attr_accessor :url_root, :id_attribute, :token, :api_key, :endpoint
|
4
4
|
|
5
|
-
# These MUST be declared in the inheriting classes
|
6
|
-
URL_ROOT = ""
|
7
|
-
ID_ATTRIBUTE = ""
|
8
|
-
|
9
5
|
def initialize(values_hash={})
|
10
6
|
if values_hash[:url_root]
|
11
7
|
@url_root = values_hash[:url_root]
|
@@ -119,6 +115,8 @@ module SlidePay
|
|
119
115
|
end
|
120
116
|
|
121
117
|
class << self
|
118
|
+
attr_accessor :url_root, :id_attribute
|
119
|
+
|
122
120
|
def api_resource_array_from_response(response)
|
123
121
|
resources_array = []
|
124
122
|
if response.was_successful? and response.data != nil
|
@@ -131,23 +129,19 @@ module SlidePay
|
|
131
129
|
resources_array
|
132
130
|
end
|
133
131
|
|
134
|
-
|
135
132
|
def retrieve(token=nil, api_key=nil, endpoint=nil)
|
136
|
-
response = SlidePay.get(path:
|
133
|
+
response = SlidePay.get(path: @url_root, token: token, api_key: api_key, endpoint: endpoint)
|
137
134
|
|
138
135
|
return api_resource_array_from_response(response)
|
139
136
|
end
|
140
137
|
|
141
138
|
def find(search_params, token=nil, api_key=nil, endpoint=nil)
|
142
|
-
# Make sure the search parameters are valid
|
143
|
-
# raise Exception.new("Invalid search filter supplied.") unless validate_search_filters(search_params)
|
144
|
-
|
145
139
|
if search_params.is_a? Hash
|
146
140
|
search_params = [search_params]
|
147
141
|
elsif not search_params.is_a? Array
|
148
142
|
raise Exception.new("Invalid or no search filter supplied.")
|
149
143
|
end
|
150
|
-
response = SlidePay.put(path:
|
144
|
+
response = SlidePay.put(path: @url_root, data: search_params.to_json, token: token, api_key: api_key, endpoint: endpoint)
|
151
145
|
|
152
146
|
return api_resource_array_from_response(response)
|
153
147
|
end
|
@@ -1,11 +1,11 @@
|
|
1
1
|
module SlidePay
|
2
2
|
class Payment < ApiResource
|
3
|
-
|
4
|
-
|
3
|
+
@url_root = "payment"
|
4
|
+
@id_attribute = "payment_id"
|
5
5
|
|
6
6
|
def initialize(values_hash={})
|
7
|
-
@id_attribute = "payment_id"
|
8
7
|
@url_root = "payment"
|
8
|
+
@id_attribute = "payment_id"
|
9
9
|
|
10
10
|
super(values_hash)
|
11
11
|
end
|
data/lib/slidepay/version.rb
CHANGED
@@ -0,0 +1,24 @@
|
|
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
|
+
ar = ApiResource.new()
|
14
|
+
|
15
|
+
ar.url_root = "company"
|
16
|
+
ar.id_attribute = "company_id"
|
17
|
+
|
18
|
+
ar['company_id'] = 18
|
19
|
+
|
20
|
+
ar.retrieve()
|
21
|
+
|
22
|
+
puts "Company: #{ar}"
|
23
|
+
|
24
|
+
|
data/spec/payment_spec.rb
CHANGED
@@ -2,14 +2,15 @@ require "slidepay"
|
|
2
2
|
require "spec_helper"
|
3
3
|
|
4
4
|
describe SlidePay::Payment do
|
5
|
-
describe "class
|
5
|
+
describe "class instance variables" do
|
6
6
|
it "should include an id_attribute" do
|
7
|
-
expect(SlidePay::Payment
|
7
|
+
expect(SlidePay::Payment.id_attribute).to eq("payment_id")
|
8
8
|
end
|
9
9
|
|
10
10
|
it "should include a root url" do
|
11
|
-
expect(SlidePay::Payment
|
11
|
+
expect(SlidePay::Payment.url_root).to eq("payment")
|
12
12
|
end
|
13
|
+
|
13
14
|
end
|
14
15
|
|
15
16
|
it "should have an id_attribute" do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
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.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matt Rothstein
|
@@ -160,7 +160,9 @@ 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
|
163
164
|
- lib/slidepay/resources/customer.rb
|
165
|
+
- lib/slidepay/resources/location.rb
|
164
166
|
- lib/slidepay/resources/payment.rb
|
165
167
|
- lib/slidepay/resources/user_master.rb
|
166
168
|
- lib/slidepay/response.rb
|
@@ -169,6 +171,7 @@ files:
|
|
169
171
|
- scenarios/example.rb
|
170
172
|
- scenarios/payment_find_where_id.rb
|
171
173
|
- scenarios/payment_find_where_under_review.rb
|
174
|
+
- scenarios/use_api_resource_for_arbitrary_object.rb
|
172
175
|
- scenarios/user_master_find_with_first_name_fragment.rb
|
173
176
|
- scenarios/user_master_retrieve.rb
|
174
177
|
- slidepay.gemspec
|