retentiongrid 0.1.1 → 0.2.0
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/retentiongrid/api.rb +6 -3
- data/lib/retentiongrid/customer.rb +1 -4
- data/lib/retentiongrid/order.rb +1 -4
- data/lib/retentiongrid/product.rb +1 -1
- data/lib/retentiongrid/resource.rb +0 -5
- data/lib/retentiongrid/version.rb +1 -1
- data/lib/retentiongrid.rb +0 -1
- data/retentiongrid.gemspec +0 -3
- data/spec/integration/customer_spec.rb +0 -4
- data/spec/integration/product_spec.rb +0 -8
- data/spec/models/customer_spec.rb +2 -4
- data/spec/models/order_spec.rb +2 -7
- data/spec/models/product_spec.rb +4 -0
- data/spec/spec_helper.rb +0 -1
- metadata +2 -30
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8d0fa613d3babf6c177b1aac2f3ee7cd0fe7a1af
|
4
|
+
data.tar.gz: 625ee2cab1d11aacd52ba112ee8a206e1ffef971
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5aba78ecd284681abec3f5389656d0c4616f9e9d81475dc7212fd1a03998aa309640a789d7bfb969e3fe2ea66f295e77737f434364bd824c7fb172fd451b9e9f
|
7
|
+
data.tar.gz: 27025e4f718fc732c5467b8aef7d64d9fa4b6a89864cd072ba05c6a7b9c5c49db93a82e24ab4431217e013aca56c4262534c4f3d7a959205dc2703d7ff51f539
|
data/lib/retentiongrid/api.rb
CHANGED
@@ -34,7 +34,8 @@ module Retentiongrid
|
|
34
34
|
def get_with_response_check(*args)
|
35
35
|
check_response_codes(get_without_response_check(*args))
|
36
36
|
end
|
37
|
-
|
37
|
+
alias_method :get_without_response_check, :get
|
38
|
+
alias_method :get, :get_with_response_check
|
38
39
|
|
39
40
|
# Do a HTTP POST requests with the given arguments
|
40
41
|
# and then check for the response code.
|
@@ -46,7 +47,8 @@ module Retentiongrid
|
|
46
47
|
def post_with_response_check(*args)
|
47
48
|
check_response_codes(post_without_response_check(*args))
|
48
49
|
end
|
49
|
-
|
50
|
+
alias_method :post_without_response_check, :post
|
51
|
+
alias_method :post, :post_with_response_check
|
50
52
|
|
51
53
|
# Do a HTTP DELETE requests with the given arguments
|
52
54
|
# and then check for the response code.
|
@@ -58,7 +60,8 @@ module Retentiongrid
|
|
58
60
|
def delete_with_response_check(*args)
|
59
61
|
check_response_codes(delete_without_response_check(*args))
|
60
62
|
end
|
61
|
-
|
63
|
+
alias_method :delete_without_response_check, :delete
|
64
|
+
alias_method :delete, :delete_with_response_check
|
62
65
|
|
63
66
|
end
|
64
67
|
|
@@ -9,9 +9,8 @@ module Retentiongrid
|
|
9
9
|
# customer = Retentiongrid::Customer.find('C123')
|
10
10
|
#
|
11
11
|
class Customer < Resource
|
12
|
-
include ActiveModel::Validations
|
13
12
|
|
14
|
-
BASE_PATH = '/customers'
|
13
|
+
BASE_PATH = '/customers'.freeze
|
15
14
|
|
16
15
|
# The set of attributes defined by the API documentation
|
17
16
|
ATTRIBUTES_NAMES = [ :customer_id, :full_name, :first_name, :email,
|
@@ -22,8 +21,6 @@ module Retentiongrid
|
|
22
21
|
attr_accessor attrib
|
23
22
|
end
|
24
23
|
|
25
|
-
validates :customer_id, :full_name, presence: true
|
26
|
-
|
27
24
|
# API Stuff here
|
28
25
|
|
29
26
|
# Find a customer with given id
|
data/lib/retentiongrid/order.rb
CHANGED
@@ -8,9 +8,8 @@ module Retentiongrid
|
|
8
8
|
# order = Retentiongrid::Order.find('A123')
|
9
9
|
#
|
10
10
|
class Order < Resource
|
11
|
-
include ActiveModel::Validations
|
12
11
|
|
13
|
-
BASE_PATH = '/orders'
|
12
|
+
BASE_PATH = '/orders'.freeze
|
14
13
|
|
15
14
|
# The set of attributes defined by the API documentation
|
16
15
|
ATTRIBUTES_NAMES = [ :order_id, :customer_id, :status, :total_price, :total_discounts,
|
@@ -23,8 +22,6 @@ module Retentiongrid
|
|
23
22
|
|
24
23
|
attr_accessor :customer
|
25
24
|
|
26
|
-
validates :order_id, :customer_id, :currency, :total_price, :order_created_at, presence: true
|
27
|
-
|
28
25
|
def initialize(attribs={})
|
29
26
|
super
|
30
27
|
@order_created_at = Time.parse(order_created_at) unless order_created_at.nil?
|
@@ -4,7 +4,6 @@ module Retentiongrid
|
|
4
4
|
# Base class for all API resources.
|
5
5
|
#
|
6
6
|
class Resource
|
7
|
-
include ActiveModel::Validations
|
8
7
|
|
9
8
|
ATTRIBUTES_NAMES = []
|
10
9
|
|
@@ -12,10 +11,6 @@ module Retentiongrid
|
|
12
11
|
attr_accessor attrib
|
13
12
|
end
|
14
13
|
|
15
|
-
def self.base_path
|
16
|
-
'/'
|
17
|
-
end
|
18
|
-
|
19
14
|
def initialize(attribs={})
|
20
15
|
attribs.each do |attrib, value|
|
21
16
|
self.send("#{attrib}=", value)
|
data/lib/retentiongrid.rb
CHANGED
data/retentiongrid.gemspec
CHANGED
@@ -20,15 +20,12 @@ Gem::Specification.new do |spec|
|
|
20
20
|
spec.require_paths = ["lib"]
|
21
21
|
|
22
22
|
spec.add_dependency 'httparty', '0.13.1'
|
23
|
-
spec.add_dependency 'activemodel', '>=3.2.0'
|
24
|
-
|
25
23
|
|
26
24
|
spec.add_development_dependency 'bundler', '~> 1.6'
|
27
25
|
spec.add_development_dependency 'rake'
|
28
26
|
spec.add_development_dependency 'yard'
|
29
27
|
|
30
28
|
spec.add_development_dependency 'rspec'
|
31
|
-
spec.add_development_dependency 'shoulda-matchers'
|
32
29
|
spec.add_development_dependency 'webmock'
|
33
30
|
spec.add_development_dependency 'factory_girl'
|
34
31
|
|
@@ -49,10 +49,6 @@ RSpec.describe Customer do
|
|
49
49
|
|
50
50
|
context '#delete' do
|
51
51
|
|
52
|
-
subject do
|
53
|
-
FactoryGirl.build(:customer)
|
54
|
-
end
|
55
|
-
|
56
52
|
before :each do
|
57
53
|
stub_request(:delete, "http://retentiongrid.apiary-mock.com/customers/#{subject.customer_id}").to_return(:status => 204, :body => '')
|
58
54
|
end
|
@@ -83,14 +83,6 @@ RSpec.describe Product do
|
|
83
83
|
|
84
84
|
context '#delete' do
|
85
85
|
|
86
|
-
let :product do
|
87
|
-
FactoryGirl.build(:product)
|
88
|
-
end
|
89
|
-
|
90
|
-
subject do
|
91
|
-
FactoryGirl.build(:product)
|
92
|
-
end
|
93
|
-
|
94
86
|
before :each do
|
95
87
|
stub_request(:delete, "http://retentiongrid.apiary-mock.com/products/#{subject.product_id}").to_return(:status => 204, :body => '')
|
96
88
|
end
|
@@ -6,10 +6,8 @@ RSpec.describe Customer do
|
|
6
6
|
FactoryGirl.build(:customer)
|
7
7
|
end
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
it { expect(subject).to validate_presence_of :full_name }
|
12
|
-
it { expect(subject).to be_valid }
|
9
|
+
it "sets the base path correctly" do
|
10
|
+
expect(Customer::BASE_PATH).to eql '/customers'
|
13
11
|
end
|
14
12
|
|
15
13
|
it "makes sure the customer id is populated" do
|
data/spec/models/order_spec.rb
CHANGED
@@ -10,13 +10,8 @@ RSpec.describe Order do
|
|
10
10
|
FactoryGirl.build(:order, customer: customer)
|
11
11
|
end
|
12
12
|
|
13
|
-
|
14
|
-
|
15
|
-
it { expect(subject).to validate_presence_of :customer_id }
|
16
|
-
it { expect(subject).to validate_presence_of :currency }
|
17
|
-
it { expect(subject).to validate_presence_of :total_price }
|
18
|
-
it { expect(subject).to validate_presence_of :order_created_at }
|
19
|
-
it { expect(subject).to be_valid }
|
13
|
+
it "sets the base path correctly" do
|
14
|
+
expect(Order::BASE_PATH).to eql '/orders'
|
20
15
|
end
|
21
16
|
|
22
17
|
it "makes sure the order id is populated" do
|
data/spec/models/product_spec.rb
CHANGED
@@ -6,6 +6,10 @@ RSpec.describe Product do
|
|
6
6
|
FactoryGirl.build(:product)
|
7
7
|
end
|
8
8
|
|
9
|
+
it "sets the base path correctly" do
|
10
|
+
expect(Product::BASE_PATH).to eql '/products'
|
11
|
+
end
|
12
|
+
|
9
13
|
it "makes sure the product id is populated" do
|
10
14
|
expect(subject.product_id).to_not eql nil
|
11
15
|
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: retentiongrid
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Christoph Bünte
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-10-
|
11
|
+
date: 2014-10-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|
@@ -24,20 +24,6 @@ dependencies:
|
|
24
24
|
- - '='
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 0.13.1
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: activemodel
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - ">="
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: 3.2.0
|
34
|
-
type: :runtime
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - ">="
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: 3.2.0
|
41
27
|
- !ruby/object:Gem::Dependency
|
42
28
|
name: bundler
|
43
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -94,20 +80,6 @@ dependencies:
|
|
94
80
|
- - ">="
|
95
81
|
- !ruby/object:Gem::Version
|
96
82
|
version: '0'
|
97
|
-
- !ruby/object:Gem::Dependency
|
98
|
-
name: shoulda-matchers
|
99
|
-
requirement: !ruby/object:Gem::Requirement
|
100
|
-
requirements:
|
101
|
-
- - ">="
|
102
|
-
- !ruby/object:Gem::Version
|
103
|
-
version: '0'
|
104
|
-
type: :development
|
105
|
-
prerelease: false
|
106
|
-
version_requirements: !ruby/object:Gem::Requirement
|
107
|
-
requirements:
|
108
|
-
- - ">="
|
109
|
-
- !ruby/object:Gem::Version
|
110
|
-
version: '0'
|
111
83
|
- !ruby/object:Gem::Dependency
|
112
84
|
name: webmock
|
113
85
|
requirement: !ruby/object:Gem::Requirement
|