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 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 "faraday_middleware"
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 "fakeweb"
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.7)
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
- fakeweb
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
@@ -6,6 +6,10 @@ module Shopkit
6
6
  get('/orders', options)['orders']
7
7
  end
8
8
 
9
+ def order(id, options={})
10
+ get("/orders/#{id}", options)['order']
11
+ end
12
+
9
13
  end
10
14
 
11
15
  include Orders
@@ -0,0 +1,13 @@
1
+ module Shopkit
2
+ class Client
3
+ module Webhooks
4
+
5
+ def create_webhook(options={})
6
+ post('/webhooks', options)['webhook']
7
+ end
8
+
9
+ end
10
+
11
+ include Webhooks
12
+ end
13
+ end
@@ -7,6 +7,7 @@ module Shopkit
7
7
  private
8
8
 
9
9
  def connection
10
+ #@conn ||= Faraday.new(:url => "https://#{url}") do |builder|
10
11
  @conn ||= Faraday.new(:url => "http://#{url}") do |builder|
11
12
  builder.request :oauth2, access_token
12
13
  #builder.request :json
@@ -1,5 +1,3 @@
1
- require 'multi_json'
2
-
3
1
  module Shopkit
4
2
  module Request
5
3
  def delete(path, options={}, version=api_version)
@@ -1,3 +1,3 @@
1
1
  module Shopkit
2
- VERSION = "0.1.0" unless defined?(Shopkit::VERSION)
2
+ VERSION = "0.1.1" unless defined?(Shopkit::VERSION)
3
3
  end
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.0"
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-06-27"
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<faraday_middleware>, [">= 0"])
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<fakeweb>, [">= 0"])
67
+ s.add_development_dependency(%q<webmock>, ["~> 1.8.7"])
63
68
  else
64
- s.add_dependency(%q<faraday_middleware>, [">= 0"])
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<fakeweb>, [">= 0"])
76
+ s.add_dependency(%q<webmock>, ["~> 1.8.7"])
71
77
  end
72
78
  else
73
- s.add_dependency(%q<faraday_middleware>, [">= 0"])
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<fakeweb>, [">= 0"])
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
+ }
@@ -0,0 +1,8 @@
1
+ {
2
+ "webhook":
3
+ {
4
+ "id": 1,
5
+ "event": "order/fulfilled",
6
+ "callback_url": "http://lvh.me/webhook"
7
+ }
8
+ }
@@ -2,12 +2,15 @@ require 'spec_helper'
2
2
 
3
3
  describe Shopkit::Client::Orders do
4
4
 
5
- before do
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 orders' do
10
- Shopkit.orders.size.should_not eql 0
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
- body = options.has_key?(:body) ? options.delete(:body) : load_json(endpoint)
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
- FakeWeb.register_uri(method, url, {:body => body, :content_type => "text/json"}.merge(options))
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.0
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-06-27 00:00:00.000000000 Z
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: '0'
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: '0'
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: fakeweb
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: '0'
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: '0'
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: -789845379
194
+ hash: 15336915
175
195
  required_rubygems_version: !ruby/object:Gem::Requirement
176
196
  none: false
177
197
  requirements: