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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 839d8bb9d4357f5100981437e1791bdeedd6f530
4
- data.tar.gz: 526f6ae7eb6d4442e3df4ac560b8ea5cea9aaad2
3
+ metadata.gz: f9b907bd0318a7474ca1e14f87e2f69dcd6c4641
4
+ data.tar.gz: 4441fdaabad3b64ac037d170b05ef6674d5c77e1
5
5
  SHA512:
6
- metadata.gz: 9a2db2d5be46bb285825e83ad3a33c22d3bea52d64ba4d130d33c1d4758dba04bb2765cc3d37afd598402e8d8f1ebc307a59de819dd1211c9f2ee4da0693029c
7
- data.tar.gz: cc17e9edc84517b67148040bf6eef121751c72745eda02914fb442277ad54df58da46f4703809f77f9325239fa1095d5cff779eba3c15ab990f7acb4a55fc46a
6
+ metadata.gz: beab9943102814e514e72881e334f39fe659b5fd6a2a97d49fce89208ecb4e5d2087fa62954496363b27d833eec4a7ef71ca02e786a6c1d7823cde1ddef473a5
7
+ data.tar.gz: 0ab42fd162f60a59b17776110dcd371de6d1aecfcc8284fb6c452003d3206078e5f54f05a8299c18a1393f118246377657170e756f5678c8531ccbacbf96a557
@@ -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
@@ -1,5 +1,8 @@
1
1
  module SlidePay
2
2
  class ApiKey < ApiResource
3
+ @url_root = "api_key"
4
+ @id_attribute = "api_key_id"
5
+
3
6
  def initialize(values_hash={})
4
7
  @url_root = "api_key"
5
8
  @id_attribute = "api_key_id"
@@ -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: self::URL_ROOT, token: token, api_key: api_key, endpoint: endpoint)
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: self::URL_ROOT, data: search_params.to_json, token: token, api_key: api_key, endpoint: endpoint)
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,5 +1,8 @@
1
1
  module SlidePay
2
2
  class BankAccount < ApiResource
3
+ @url_root = "bank_account"
4
+ @id_attribute = "bank_account_id"
5
+
3
6
  def initialize(values_hash={})
4
7
  @url_root = "bank_account"
5
8
  @id_attribute = "bank_account_id"
@@ -0,0 +1,14 @@
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,5 +1,8 @@
1
1
  module SlidePay
2
- class ApiKey < ApiResource
2
+ class Customer < ApiResource
3
+ @url_root = "customer"
4
+ @id_attribute = "customer_id"
5
+
3
6
  def initialize(values_hash={})
4
7
  @url_root = "customer"
5
8
  @id_attribute = "customer_id"
@@ -0,0 +1,14 @@
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,11 +1,11 @@
1
1
  module SlidePay
2
2
  class Payment < ApiResource
3
- URL_ROOT = "payment"
4
- ID_ATTRIBUTE = "payment_id"
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
@@ -1,7 +1,7 @@
1
1
  module SlidePay
2
2
  class UserMaster < ApiResource
3
- URL_ROOT = "user_master"
4
- ID_ATTRIBUTE = "user_master_id"
3
+ @url_root = "user_master"
4
+ @id_attribute = "user_master_id"
5
5
 
6
6
  def initialize(values_hash={})
7
7
  @url_root = "user_master"
@@ -1,3 +1,3 @@
1
1
  module SlidePay
2
- VERSION = "0.0.9"
2
+ VERSION = "0.0.10"
3
3
  end
@@ -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
+
@@ -2,14 +2,15 @@ require "slidepay"
2
2
  require "spec_helper"
3
3
 
4
4
  describe SlidePay::Payment do
5
- describe "class constants" do
5
+ describe "class instance variables" do
6
6
  it "should include an id_attribute" do
7
- expect(SlidePay::Payment::ID_ATTRIBUTE).to eq("payment_id")
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::URL_ROOT).to eq("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.9
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