celery_api 0.0.8 → 0.0.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/celery.rb +1 -0
- data/lib/celery/order.rb +11 -6
- data/lib/celery/shop.rb +31 -0
- data/lib/celery/version.rb +1 -1
- data/spec/celery/shop_spec.rb +13 -0
- data/spec/spec_helper.rb +1 -1
- metadata +12 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 01aefa17f5ba786cde081f4048e3a0c08874e8b7
|
4
|
+
data.tar.gz: f9193994908e96222c3100495a8c2cf80a27d435
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5b5d02e34bce14a1a2a1193887b4de4d2658945051d367d73b941959cf8237428d531cdd85f821a0dfdb172824ca90085e5e813e044f81fb5122bd0551148742
|
7
|
+
data.tar.gz: 3d7ae03df52f197507f66de634165a719de800484dfad088730c74aa2469cf6ac46451a4c0384561f9655275d0f45cb98f582d6d0a56212692c8663f979107e7
|
data/lib/celery.rb
CHANGED
data/lib/celery/order.rb
CHANGED
@@ -39,25 +39,30 @@ module Celery
|
|
39
39
|
end
|
40
40
|
|
41
41
|
def cancel
|
42
|
-
response =
|
43
|
-
"#{self.class.endpoint_path}/#{self.id}/cancel?#{self.class.options}"
|
44
|
-
)
|
42
|
+
response = endpoint_call(:get, "cancel")
|
45
43
|
return true if response[self.class.object_root]
|
46
44
|
end
|
47
45
|
|
48
46
|
def charge_deposit
|
49
|
-
response =
|
50
|
-
"#{self.class.endpoint_path}/#{self.id}/charge_deposit?#{self.class.options}"
|
51
|
-
)
|
47
|
+
response = endpoint_call(:post, "charge_deposit")
|
52
48
|
return true if response[self.class.object_root]
|
53
49
|
end
|
54
50
|
|
51
|
+
|
55
52
|
class << self
|
56
53
|
def decode(encoded_string)
|
57
54
|
decoded_string = Base64.decode64(encoded_string)
|
58
55
|
Celery::Order.new(JSON.parse(decoded_string))
|
59
56
|
end
|
60
57
|
end
|
58
|
+
|
59
|
+
private
|
60
|
+
def endpoint_call(http_verb, method)
|
61
|
+
HTTParty.send(
|
62
|
+
http_verb,
|
63
|
+
"#{self.class.endpoint_path}/#{self.id}/#{method}?#{self.class.options}"
|
64
|
+
)
|
65
|
+
end
|
61
66
|
end
|
62
67
|
|
63
68
|
end
|
data/lib/celery/shop.rb
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
module Celery
|
2
|
+
|
3
|
+
class Shop < Base
|
4
|
+
attr_accessor :_id, :analytics, :notes, :campaign, :created,
|
5
|
+
:created_date, :css, :deposit, :description, :extras, :flags,
|
6
|
+
:image, :metadata, :name, :options, :pitch, :price, :published,
|
7
|
+
:quantity_limit, :shipping, :slug, :tagline, :updated, :updated_date,
|
8
|
+
:user_id, :video
|
9
|
+
|
10
|
+
class << self
|
11
|
+
def get(slug)
|
12
|
+
response = HTTParty.get("#{endpoint_path}/#{slug}")
|
13
|
+
Celery::Product.new(response["product"])
|
14
|
+
end
|
15
|
+
|
16
|
+
def slugify(slug)
|
17
|
+
response = HTTParty.get("#{Celery.endpoint}slugify?slug=#{slug}")
|
18
|
+
return response["slugify"]
|
19
|
+
end
|
20
|
+
|
21
|
+
def endpoint_path
|
22
|
+
Celery.endpoint + "shop"
|
23
|
+
end
|
24
|
+
|
25
|
+
def options(args={})
|
26
|
+
Celery.parameterize_options(args)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
data/lib/celery/version.rb
CHANGED
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Celery::Shop, 'class methods' do
|
4
|
+
let!(:product) { Celery::Product.all.first }
|
5
|
+
|
6
|
+
it 'gets the shop using the SLUG' do
|
7
|
+
expect(Celery::Shop.get(product.slug)).to be_kind_of Celery::Product
|
8
|
+
end
|
9
|
+
|
10
|
+
it 'checks if a product is present' do
|
11
|
+
expect(Celery::Shop.slugify(product.slug)).to eq(false)
|
12
|
+
end
|
13
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -7,7 +7,7 @@ CodeClimate::TestReporter.start
|
|
7
7
|
|
8
8
|
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
|
9
9
|
|
10
|
-
Celery.access_token = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiI1Mzg4ZTcxYzVkNTE5NDA1MDA0ZTNjM2MifQ.
|
10
|
+
Celery.access_token = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiI1Mzg4ZTcxYzVkNTE5NDA1MDA0ZTNjM2MifQ.Vw1dikATVaAK5YLZFTPOXKpJJexa8T6Ni1RuE3nh1nAU"
|
11
11
|
|
12
12
|
I18n.enforce_available_locales = true
|
13
13
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: celery_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Antonio Chavez
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2014-07-
|
13
|
+
date: 2014-07-04 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: httparty
|
@@ -186,6 +186,7 @@ files:
|
|
186
186
|
- lib/celery/order.rb
|
187
187
|
- lib/celery/product.rb
|
188
188
|
- lib/celery/seller.rb
|
189
|
+
- lib/celery/shop.rb
|
189
190
|
- lib/celery/tracking.rb
|
190
191
|
- lib/celery/user.rb
|
191
192
|
- lib/celery/version.rb
|
@@ -194,6 +195,7 @@ files:
|
|
194
195
|
- spec/celery/buyer_spec.rb
|
195
196
|
- spec/celery/order_spec.rb
|
196
197
|
- spec/celery/product_spec.rb
|
198
|
+
- spec/celery/shop_spec.rb
|
197
199
|
- spec/celery/user_spec.rb
|
198
200
|
- spec/celery_spec.rb
|
199
201
|
- spec/spec_helper.rb
|
@@ -224,12 +226,13 @@ signing_key:
|
|
224
226
|
specification_version: 4
|
225
227
|
summary: Celery API wrapper
|
226
228
|
test_files:
|
227
|
-
- spec/spec_helper.rb
|
228
|
-
- spec/celery_spec.rb
|
229
|
-
- spec/support/fixtures/celery_encoded_order.txt
|
230
|
-
- spec/support/celery_order_helper.rb
|
231
|
-
- spec/celery/user_spec.rb
|
232
|
-
- spec/celery/buyer_spec.rb
|
233
229
|
- spec/celery/base_spec.rb
|
234
|
-
- spec/celery/
|
230
|
+
- spec/celery/buyer_spec.rb
|
235
231
|
- spec/celery/order_spec.rb
|
232
|
+
- spec/celery/product_spec.rb
|
233
|
+
- spec/celery/shop_spec.rb
|
234
|
+
- spec/celery/user_spec.rb
|
235
|
+
- spec/celery_spec.rb
|
236
|
+
- spec/spec_helper.rb
|
237
|
+
- spec/support/celery_order_helper.rb
|
238
|
+
- spec/support/fixtures/celery_encoded_order.txt
|