shopkit 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +3 -2
- data/Gemfile.lock +9 -4
- data/lib/shopkit/client/orders.rb +4 -0
- data/lib/shopkit/client/webhooks.rb +13 -0
- data/lib/shopkit/connection.rb +1 -0
- data/lib/shopkit/request.rb +0 -2
- data/lib/shopkit/version.rb +1 -1
- data/shopkit.gemspec +15 -8
- data/spec/json/order.json +27 -0
- data/spec/json/webhook.json +8 -0
- data/spec/shopkit/client/orders_spec.rb +6 -3
- data/spec/shopkit/client/webhooks_spec.rb +14 -0
- data/spec/spec_helper.rb +6 -5
- metadata +32 -12
data/Gemfile
CHANGED
@@ -2,7 +2,8 @@ source "http://rubygems.org"
|
|
2
2
|
# Add dependencies required to use your gem here.
|
3
3
|
# Example:
|
4
4
|
# gem "activesupport", ">= 2.3.5"
|
5
|
-
gem "
|
5
|
+
gem "faraday", "~> 0.8.1"
|
6
|
+
gem "faraday_middleware", "~> 0.8.8"
|
6
7
|
|
7
8
|
# Add dependencies to develop your gem here.
|
8
9
|
# Include everything needed to run rake, tests, features, etc.
|
@@ -12,5 +13,5 @@ group :development do
|
|
12
13
|
gem "bundler"
|
13
14
|
gem "jeweler"
|
14
15
|
gem "rspec"
|
15
|
-
gem "
|
16
|
+
gem "webmock", "~> 1.8.7"
|
16
17
|
end
|
data/Gemfile.lock
CHANGED
@@ -1,11 +1,12 @@
|
|
1
1
|
GEM
|
2
2
|
remote: http://rubygems.org/
|
3
3
|
specs:
|
4
|
+
addressable (2.2.8)
|
5
|
+
crack (0.3.1)
|
4
6
|
diff-lcs (1.1.3)
|
5
|
-
fakeweb (1.3.0)
|
6
7
|
faraday (0.8.1)
|
7
8
|
multipart-post (~> 1.1)
|
8
|
-
faraday_middleware (0.8.
|
9
|
+
faraday_middleware (0.8.8)
|
9
10
|
faraday (>= 0.7.4, < 0.9)
|
10
11
|
git (1.2.5)
|
11
12
|
jeweler (1.8.3)
|
@@ -31,6 +32,9 @@ GEM
|
|
31
32
|
shoulda-matchers (~> 1.0.0)
|
32
33
|
shoulda-context (1.0.0)
|
33
34
|
shoulda-matchers (1.0.0)
|
35
|
+
webmock (1.8.7)
|
36
|
+
addressable (>= 2.2.7)
|
37
|
+
crack (>= 0.1.7)
|
34
38
|
yard (0.8.1)
|
35
39
|
|
36
40
|
PLATFORMS
|
@@ -38,9 +42,10 @@ PLATFORMS
|
|
38
42
|
|
39
43
|
DEPENDENCIES
|
40
44
|
bundler
|
41
|
-
|
42
|
-
faraday_middleware
|
45
|
+
faraday (~> 0.8.1)
|
46
|
+
faraday_middleware (~> 0.8.8)
|
43
47
|
jeweler
|
44
48
|
rspec
|
45
49
|
shoulda
|
50
|
+
webmock (~> 1.8.7)
|
46
51
|
yard
|
data/lib/shopkit/connection.rb
CHANGED
data/lib/shopkit/request.rb
CHANGED
data/lib/shopkit/version.rb
CHANGED
data/shopkit.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "shopkit"
|
8
|
-
s.version = "0.1.
|
8
|
+
s.version = "0.1.1"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["saberma"]
|
12
|
-
s.date = "2012-
|
12
|
+
s.date = "2012-07-13"
|
13
13
|
s.description = "a gem for the ShopQi API"
|
14
14
|
s.email = "mahb45@gmail.com"
|
15
15
|
s.extra_rdoc_files = [
|
@@ -30,17 +30,21 @@ Gem::Specification.new do |s|
|
|
30
30
|
"lib/shopkit/client/orders.rb",
|
31
31
|
"lib/shopkit/client/products.rb",
|
32
32
|
"lib/shopkit/client/shop.rb",
|
33
|
+
"lib/shopkit/client/webhooks.rb",
|
33
34
|
"lib/shopkit/configuration.rb",
|
34
35
|
"lib/shopkit/connection.rb",
|
35
36
|
"lib/shopkit/request.rb",
|
36
37
|
"lib/shopkit/version.rb",
|
37
38
|
"shopkit.gemspec",
|
39
|
+
"spec/json/order.json",
|
38
40
|
"spec/json/orders.json",
|
39
41
|
"spec/json/products.json",
|
40
42
|
"spec/json/shop.json",
|
43
|
+
"spec/json/webhook.json",
|
41
44
|
"spec/shopkit/client/orders_spec.rb",
|
42
45
|
"spec/shopkit/client/products_spec.rb",
|
43
46
|
"spec/shopkit/client/shop_spec.rb",
|
47
|
+
"spec/shopkit/client/webhooks_spec.rb",
|
44
48
|
"spec/spec_helper.rb"
|
45
49
|
]
|
46
50
|
s.homepage = "http://github.com/saberma/shopkit"
|
@@ -53,30 +57,33 @@ Gem::Specification.new do |s|
|
|
53
57
|
s.specification_version = 3
|
54
58
|
|
55
59
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
56
|
-
s.add_runtime_dependency(%q<
|
60
|
+
s.add_runtime_dependency(%q<faraday>, ["~> 0.8.1"])
|
61
|
+
s.add_runtime_dependency(%q<faraday_middleware>, ["~> 0.8.8"])
|
57
62
|
s.add_development_dependency(%q<shoulda>, [">= 0"])
|
58
63
|
s.add_development_dependency(%q<yard>, [">= 0"])
|
59
64
|
s.add_development_dependency(%q<bundler>, [">= 0"])
|
60
65
|
s.add_development_dependency(%q<jeweler>, [">= 0"])
|
61
66
|
s.add_development_dependency(%q<rspec>, [">= 0"])
|
62
|
-
s.add_development_dependency(%q<
|
67
|
+
s.add_development_dependency(%q<webmock>, ["~> 1.8.7"])
|
63
68
|
else
|
64
|
-
s.add_dependency(%q<
|
69
|
+
s.add_dependency(%q<faraday>, ["~> 0.8.1"])
|
70
|
+
s.add_dependency(%q<faraday_middleware>, ["~> 0.8.8"])
|
65
71
|
s.add_dependency(%q<shoulda>, [">= 0"])
|
66
72
|
s.add_dependency(%q<yard>, [">= 0"])
|
67
73
|
s.add_dependency(%q<bundler>, [">= 0"])
|
68
74
|
s.add_dependency(%q<jeweler>, [">= 0"])
|
69
75
|
s.add_dependency(%q<rspec>, [">= 0"])
|
70
|
-
s.add_dependency(%q<
|
76
|
+
s.add_dependency(%q<webmock>, ["~> 1.8.7"])
|
71
77
|
end
|
72
78
|
else
|
73
|
-
s.add_dependency(%q<
|
79
|
+
s.add_dependency(%q<faraday>, ["~> 0.8.1"])
|
80
|
+
s.add_dependency(%q<faraday_middleware>, ["~> 0.8.8"])
|
74
81
|
s.add_dependency(%q<shoulda>, [">= 0"])
|
75
82
|
s.add_dependency(%q<yard>, [">= 0"])
|
76
83
|
s.add_dependency(%q<bundler>, [">= 0"])
|
77
84
|
s.add_dependency(%q<jeweler>, [">= 0"])
|
78
85
|
s.add_dependency(%q<rspec>, [">= 0"])
|
79
|
-
s.add_dependency(%q<
|
86
|
+
s.add_dependency(%q<webmock>, ["~> 1.8.7"])
|
80
87
|
end
|
81
88
|
end
|
82
89
|
|
@@ -0,0 +1,27 @@
|
|
1
|
+
{
|
2
|
+
"order": {
|
3
|
+
"cancel_reason": null,
|
4
|
+
"cancelled_at": null,
|
5
|
+
"closed_at": "2012-05-15T21:36:38+08:00",
|
6
|
+
"created_at": "2012-04-16T23:07:33+08:00",
|
7
|
+
"customer_id": 2,
|
8
|
+
"email": "mahb45@gmail.com",
|
9
|
+
"financial_status": "pending",
|
10
|
+
"fulfillment_status": "fulfilled",
|
11
|
+
"id": 99,
|
12
|
+
"name": "#1095",
|
13
|
+
"note": "",
|
14
|
+
"number": 95,
|
15
|
+
"order_number": 1095,
|
16
|
+
"payment_id": 8,
|
17
|
+
"shipping_rate": "普通快递-0",
|
18
|
+
"shop_id": 2,
|
19
|
+
"status": "closed",
|
20
|
+
"subtotal_price": 45.0,
|
21
|
+
"token": "96b1d0806a03012f21f6480aa969d9a6",
|
22
|
+
"total_line_items_price": 45.0,
|
23
|
+
"total_price": 45.0,
|
24
|
+
"trade_no": null,
|
25
|
+
"updated_at": "2012-05-15T21:36:38+08:00"
|
26
|
+
}
|
27
|
+
}
|
@@ -2,12 +2,15 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe Shopkit::Client::Orders do
|
4
4
|
|
5
|
-
|
5
|
+
it 'should get orders' do
|
6
6
|
fake_web "orders"
|
7
|
+
Shopkit.orders.size.should_not eql 0
|
7
8
|
end
|
8
9
|
|
9
|
-
it 'should get
|
10
|
-
|
10
|
+
it 'should get order' do
|
11
|
+
id = 99
|
12
|
+
fake_web "orders/#{id}", json_file: :order
|
13
|
+
Shopkit.order(id)['id'].should eql id
|
11
14
|
end
|
12
15
|
|
13
16
|
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Shopkit::Client::Webhooks do
|
4
|
+
|
5
|
+
before do
|
6
|
+
fake_web 'webhooks', method: :post, json_file: :webhook
|
7
|
+
end
|
8
|
+
|
9
|
+
it 'should be create' do
|
10
|
+
webhook = Shopkit.create_webhook(webhook: {event: 'order/fulfilled', callback_url: 'http://lvh.me/webhook'})
|
11
|
+
webhook['id'].should_not be_nil
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,7 +1,6 @@
|
|
1
|
-
require 'fakeweb'
|
2
1
|
require 'shopkit'
|
2
|
+
require 'webmock/rspec'
|
3
3
|
|
4
|
-
FakeWeb.allow_net_connect = false
|
5
4
|
RSpec.configure do |config|
|
6
5
|
|
7
6
|
config.before(:each) do
|
@@ -16,11 +15,13 @@ RSpec.configure do |config|
|
|
16
15
|
end
|
17
16
|
|
18
17
|
def fake_web(endpoint, options={})
|
19
|
-
|
18
|
+
file = options[:json_file] || endpoint
|
19
|
+
body = options.has_key?(:body) ? options.delete(:body) : load_json(file)
|
20
20
|
method = options.delete(:method) || :get
|
21
21
|
|
22
|
-
url = "https://#{Shopkit.url}/api/#{endpoint}.json"
|
23
|
-
|
22
|
+
#url = "https://#{Shopkit.url}/api/#{endpoint}.json"
|
23
|
+
url = "http://#{Shopkit.url}/api/#{endpoint}.json"
|
24
|
+
stub_request(method, url).to_return(body: body, headers: { content_type: 'text/json' })
|
24
25
|
end
|
25
26
|
|
26
27
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: shopkit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,24 +9,40 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-07-13 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: faraday
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 0.8.1
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 0.8.1
|
14
30
|
- !ruby/object:Gem::Dependency
|
15
31
|
name: faraday_middleware
|
16
32
|
requirement: !ruby/object:Gem::Requirement
|
17
33
|
none: false
|
18
34
|
requirements:
|
19
|
-
- -
|
35
|
+
- - ~>
|
20
36
|
- !ruby/object:Gem::Version
|
21
|
-
version:
|
37
|
+
version: 0.8.8
|
22
38
|
type: :runtime
|
23
39
|
prerelease: false
|
24
40
|
version_requirements: !ruby/object:Gem::Requirement
|
25
41
|
none: false
|
26
42
|
requirements:
|
27
|
-
- -
|
43
|
+
- - ~>
|
28
44
|
- !ruby/object:Gem::Version
|
29
|
-
version:
|
45
|
+
version: 0.8.8
|
30
46
|
- !ruby/object:Gem::Dependency
|
31
47
|
name: shoulda
|
32
48
|
requirement: !ruby/object:Gem::Requirement
|
@@ -108,21 +124,21 @@ dependencies:
|
|
108
124
|
- !ruby/object:Gem::Version
|
109
125
|
version: '0'
|
110
126
|
- !ruby/object:Gem::Dependency
|
111
|
-
name:
|
127
|
+
name: webmock
|
112
128
|
requirement: !ruby/object:Gem::Requirement
|
113
129
|
none: false
|
114
130
|
requirements:
|
115
|
-
- -
|
131
|
+
- - ~>
|
116
132
|
- !ruby/object:Gem::Version
|
117
|
-
version:
|
133
|
+
version: 1.8.7
|
118
134
|
type: :development
|
119
135
|
prerelease: false
|
120
136
|
version_requirements: !ruby/object:Gem::Requirement
|
121
137
|
none: false
|
122
138
|
requirements:
|
123
|
-
- -
|
139
|
+
- - ~>
|
124
140
|
- !ruby/object:Gem::Version
|
125
|
-
version:
|
141
|
+
version: 1.8.7
|
126
142
|
description: a gem for the ShopQi API
|
127
143
|
email: mahb45@gmail.com
|
128
144
|
executables: []
|
@@ -144,17 +160,21 @@ files:
|
|
144
160
|
- lib/shopkit/client/orders.rb
|
145
161
|
- lib/shopkit/client/products.rb
|
146
162
|
- lib/shopkit/client/shop.rb
|
163
|
+
- lib/shopkit/client/webhooks.rb
|
147
164
|
- lib/shopkit/configuration.rb
|
148
165
|
- lib/shopkit/connection.rb
|
149
166
|
- lib/shopkit/request.rb
|
150
167
|
- lib/shopkit/version.rb
|
151
168
|
- shopkit.gemspec
|
169
|
+
- spec/json/order.json
|
152
170
|
- spec/json/orders.json
|
153
171
|
- spec/json/products.json
|
154
172
|
- spec/json/shop.json
|
173
|
+
- spec/json/webhook.json
|
155
174
|
- spec/shopkit/client/orders_spec.rb
|
156
175
|
- spec/shopkit/client/products_spec.rb
|
157
176
|
- spec/shopkit/client/shop_spec.rb
|
177
|
+
- spec/shopkit/client/webhooks_spec.rb
|
158
178
|
- spec/spec_helper.rb
|
159
179
|
homepage: http://github.com/saberma/shopkit
|
160
180
|
licenses:
|
@@ -171,7 +191,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
171
191
|
version: '0'
|
172
192
|
segments:
|
173
193
|
- 0
|
174
|
-
hash:
|
194
|
+
hash: 15336915
|
175
195
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
176
196
|
none: false
|
177
197
|
requirements:
|