whiplash_api 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -38,6 +38,11 @@ require 'whiplash_api'
38
38
 
39
39
  WhiplashApi::Base.api_key = 'XXXXXXXXXXXXX'
40
40
  ```
41
+ You'll likely want to start by testing in the Sandbox:
42
+
43
+ ```
44
+ WhiplashApi::Base.test = true
45
+ ```
41
46
 
42
47
  == Usage
43
48
 
@@ -50,8 +55,14 @@ $ irb
50
55
  >
51
56
  > items = WhiplashAPI::Item.all
52
57
  >
58
+ > items = WhiplashAPI::Item.sku('SOME-SKU-111')
59
+ >
53
60
  > order = WhiplashAPI::Order.last
54
61
  >
62
+ > orders = WhiplashAPI::Order.status('shipped')
63
+ >
64
+ > order_item = WhiplashAPI::OrderItem.originator(ID_IN_YOUR_STORE)
65
+ >
55
66
  ```
56
67
 
57
68
  == Contributing to the Whiplash API Gem
@@ -8,7 +8,7 @@ module WhiplashAPI
8
8
  class Base < ActiveResource::Base
9
9
  extend WhiplashAPI
10
10
 
11
- self.site = 'http://localhost:3000/api/'
11
+ self.site = 'https://www.whiplashmerch.com/api/'
12
12
  self.format = :json
13
13
 
14
14
  # Thanks to Brandon Keepers for this little nugget:
@@ -33,6 +33,14 @@ module WhiplashAPI
33
33
  def api_version=(v)
34
34
  headers['X-API-VERSION'] = v
35
35
  end
36
+
37
+ def local=(v)
38
+ self.site = 'http://localhost:3000/api/' if v
39
+ end
40
+
41
+ def test=(v)
42
+ self.site = 'http://testing.whiplashmerch.com/api/' if v
43
+ end
36
44
 
37
45
  end
38
46
 
@@ -1,7 +1,15 @@
1
1
  module WhiplashAPI
2
2
 
3
3
  class Item < Base
4
-
4
+ class << self
5
+ def sku(sku, args={})
6
+ self.get(:sku, {:sku => sku}.merge(args))
7
+ end
8
+
9
+ def originator(id, args={})
10
+ self.get(:originator, {:originator_id => id}.merge(args))
11
+ end
12
+ end
5
13
  end
6
14
 
7
15
  end
@@ -1,7 +1,15 @@
1
1
  module WhiplashAPI
2
2
 
3
3
  class Order < Base
4
-
4
+ class << self
5
+ def status(status, args={})
6
+ self.get(:status, {:status => status}.merge(args))
7
+ end
8
+
9
+ def originator(id, args={})
10
+ self.get(:originator, {:originator_id => id}.merge(args))
11
+ end
12
+ end
5
13
  end
6
14
 
7
15
  end
@@ -1,7 +1,11 @@
1
1
  module WhiplashAPI
2
2
 
3
3
  class OrderItem < Base
4
-
4
+ class << self
5
+ def originator(id, args={})
6
+ self.get(:originator, {:originator_id => id}.merge(args))
7
+ end
8
+ end
5
9
  end
6
10
 
7
11
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: whiplash_api
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 25
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 0
9
+ - 1
10
10
  segments_generated: true
11
- version: 0.1.0
11
+ version: 0.1.1
12
12
  platform: ruby
13
13
  authors:
14
14
  - Mark Dickson
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2012-09-14 00:00:00 -04:00
19
+ date: 2012-09-17 00:00:00 -04:00
20
20
  default_executable:
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency