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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0cc326a26f45dfeeba078c3f587dda9d9c3fbb5c
4
- data.tar.gz: 541caa386fa23331f922e6bfc7576670594d5fc8
3
+ metadata.gz: 01aefa17f5ba786cde081f4048e3a0c08874e8b7
4
+ data.tar.gz: f9193994908e96222c3100495a8c2cf80a27d435
5
5
  SHA512:
6
- metadata.gz: fffd392942afbb737dbe50f6c9f4797a45ff83e4cd1368013196a991d33c5f07271a39d7e3595b71723215a20afe29fb055eb8f1d37e9c55df65ddad303f5191
7
- data.tar.gz: de0c131d54a218e2d11aabf17c3b1946f8f34cd6193d8f3ac7e266c9a8f75a56b1df58be3af11d871079aa7ebdefea481f76cd14cdfc8ba63fa00f54024dd90f
6
+ metadata.gz: 5b5d02e34bce14a1a2a1193887b4de4d2658945051d367d73b941959cf8237428d531cdd85f821a0dfdb172824ca90085e5e813e044f81fb5122bd0551148742
7
+ data.tar.gz: 3d7ae03df52f197507f66de634165a719de800484dfad088730c74aa2469cf6ac46451a4c0384561f9655275d0f45cb98f582d6d0a56212692c8663f979107e7
data/lib/celery.rb CHANGED
@@ -8,6 +8,7 @@ module Celery
8
8
  autoload :User, "celery/user"
9
9
  autoload :Base, "celery/base"
10
10
  autoload :Card, "celery/card"
11
+ autoload :Shop, "celery/shop"
11
12
  autoload :Buyer, "celery/buyer"
12
13
  autoload :Order, "celery/order"
13
14
  autoload :Seller, "celery/seller"
data/lib/celery/order.rb CHANGED
@@ -39,25 +39,30 @@ module Celery
39
39
  end
40
40
 
41
41
  def cancel
42
- response = HTTParty.get(
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 = HTTParty.post(
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
@@ -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
@@ -1,3 +1,3 @@
1
1
  module Celery
2
- VERSION = "0.0.8".freeze
2
+ VERSION = "0.0.9".freeze
3
3
  end
@@ -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.Vw1dikATVaAK5YLZFTPOXKpJJexa8T6NiRuE3nh1nAU"
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.8
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-02 00:00:00.000000000 Z
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/product_spec.rb
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