whiplash_api 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2012 Whiplash Merchandising/Mark Dickson
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,70 @@
1
+ Whiplash API V1 - Ruby Client
2
+ ================================
3
+
4
+ This library provides a wrapper around the Whiplash Merchandising REST API for use within Ruby apps or via the console.
5
+
6
+ == Note
7
+
8
+ **If you are using a Rails app, the advised approach is to use ActiveResource. You can get started or gain inspiration from our example Rails app: https://github.com/ideaoforder/whiplash-rails-example**
9
+
10
+ == Requirements
11
+
12
+ - Ruby 1.8.7+
13
+ - Rubygems
14
+ - JSON
15
+ - ActiveResource
16
+
17
+ A valid API key is required to authenticate requests. You can find your API key on your customer account page.
18
+
19
+ == Installation
20
+
21
+ ```
22
+ gem install whiplash_api
23
+ ```
24
+
25
+ Or if you're using Bundler:
26
+
27
+ ```
28
+ gem 'whiplash_api'
29
+ ```
30
+
31
+ == Configuration
32
+
33
+ To use the API client in your Ruby code, provide the required credentials as follows:
34
+
35
+ ```
36
+ require 'rubygems'
37
+ require 'whiplash_api'
38
+
39
+ WhiplashApi::Base.api_key = 'XXXXXXXXXXXXX'
40
+ ```
41
+
42
+ == Usage
43
+
44
+ The API currently gives you access to your Orders, Items, and OrderItems.
45
+
46
+ ```
47
+ $ irb
48
+ >
49
+ > WhiplashApi::Base.api_key = 'XXXXXXXXXXXXX'
50
+ >
51
+ > items = WhiplashAPI::Item.all
52
+ >
53
+ > order = WhiplashAPI::Order.last
54
+ >
55
+ ```
56
+
57
+ == Contributing to the Whiplash API Gem
58
+
59
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
60
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
61
+ * Fork the project.
62
+ * Start a feature/bugfix branch.
63
+ * Commit and push until you are happy with your contribution.
64
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
65
+ * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
66
+
67
+ == Copyright
68
+
69
+ Copyright (c) 2012 Whiplash Merchandising/Mark Dickson. See LICENSE.txt for further details.
70
+
@@ -0,0 +1,7 @@
1
+ require "rubygems"
2
+ require 'active_resource'
3
+
4
+ require 'whiplash_api/base'
5
+ require 'whiplash_api/item'
6
+ require 'whiplash_api/order'
7
+ require 'whiplash_api/order_item'
@@ -0,0 +1,46 @@
1
+ module WhiplashAPI
2
+
3
+ # Example Class Method
4
+ # def reserved(*names)
5
+ # class_variable_set(:@@reserved, names.collect{|x| x.to_s})
6
+ # end
7
+
8
+ class Base < ActiveResource::Base
9
+ extend WhiplashAPI
10
+
11
+ self.site = 'http://localhost:3000/api/'
12
+ self.format = :json
13
+
14
+ # Thanks to Brandon Keepers for this little nugget:
15
+ # http://opensoul.org/blog/archives/2010/02/16/active-resource-in-practice/
16
+ class << self
17
+ # If headers are not defined in a given subclass, then obtain
18
+ # headers from the superclass.
19
+ def headers
20
+ if defined?(@headers)
21
+ @headers
22
+ elsif superclass != Object && superclass.headers
23
+ superclass.headers
24
+ else
25
+ @headers ||= {}
26
+ end
27
+ end
28
+
29
+ def api_key=(api_key)
30
+ headers['X-API-KEY'] = api_key
31
+ end
32
+
33
+ def api_version=(v)
34
+ headers['X-API-VERSION'] = v
35
+ end
36
+
37
+ end
38
+
39
+ # Example Instance Method
40
+ # def class_name
41
+ # self.class.name.split('::').last.downcase
42
+ # end
43
+
44
+ end
45
+
46
+ end
@@ -0,0 +1,7 @@
1
+ module WhiplashAPI
2
+
3
+ class Item < Base
4
+
5
+ end
6
+
7
+ end
@@ -0,0 +1,7 @@
1
+ module WhiplashAPI
2
+
3
+ class Order < Base
4
+
5
+ end
6
+
7
+ end
@@ -0,0 +1,7 @@
1
+ module WhiplashAPI
2
+
3
+ class OrderItem < Base
4
+
5
+ end
6
+
7
+ end
metadata ADDED
@@ -0,0 +1,175 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: whiplash_api
3
+ version: !ruby/object:Gem::Version
4
+ hash: 27
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 1
9
+ - 0
10
+ segments_generated: true
11
+ version: 0.1.0
12
+ platform: ruby
13
+ authors:
14
+ - Mark Dickson
15
+ autorequire:
16
+ bindir: bin
17
+ cert_chain: []
18
+
19
+ date: 2012-09-14 00:00:00 -04:00
20
+ default_executable:
21
+ dependencies:
22
+ - !ruby/object:Gem::Dependency
23
+ prerelease: false
24
+ type: :runtime
25
+ name: activesupport
26
+ version_requirements: &id001 !ruby/object:Gem::Requirement
27
+ none: false
28
+ requirements:
29
+ - - ">="
30
+ - !ruby/object:Gem::Version
31
+ hash: 9
32
+ segments:
33
+ - 2
34
+ - 3
35
+ - 5
36
+ segments_generated: true
37
+ version: 2.3.5
38
+ requirement: *id001
39
+ - !ruby/object:Gem::Dependency
40
+ prerelease: false
41
+ type: :runtime
42
+ name: activeresource
43
+ version_requirements: &id002 !ruby/object:Gem::Requirement
44
+ none: false
45
+ requirements:
46
+ - - ">="
47
+ - !ruby/object:Gem::Version
48
+ hash: 9
49
+ segments:
50
+ - 2
51
+ - 3
52
+ - 5
53
+ segments_generated: true
54
+ version: 2.3.5
55
+ requirement: *id002
56
+ - !ruby/object:Gem::Dependency
57
+ prerelease: false
58
+ type: :development
59
+ name: rdoc
60
+ version_requirements: &id003 !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
63
+ - - ~>
64
+ - !ruby/object:Gem::Version
65
+ hash: 31
66
+ segments:
67
+ - 3
68
+ - 12
69
+ segments_generated: true
70
+ version: "3.12"
71
+ requirement: *id003
72
+ - !ruby/object:Gem::Dependency
73
+ prerelease: false
74
+ type: :development
75
+ name: bundler
76
+ version_requirements: &id004 !ruby/object:Gem::Requirement
77
+ none: false
78
+ requirements:
79
+ - - ~>
80
+ - !ruby/object:Gem::Version
81
+ hash: 23
82
+ segments:
83
+ - 1
84
+ - 0
85
+ - 0
86
+ segments_generated: true
87
+ version: 1.0.0
88
+ requirement: *id004
89
+ - !ruby/object:Gem::Dependency
90
+ prerelease: false
91
+ type: :development
92
+ name: jeweler
93
+ version_requirements: &id005 !ruby/object:Gem::Requirement
94
+ none: false
95
+ requirements:
96
+ - - ~>
97
+ - !ruby/object:Gem::Version
98
+ hash: 63
99
+ segments:
100
+ - 1
101
+ - 8
102
+ - 4
103
+ segments_generated: true
104
+ version: 1.8.4
105
+ requirement: *id005
106
+ - !ruby/object:Gem::Dependency
107
+ prerelease: false
108
+ type: :development
109
+ name: rcov
110
+ version_requirements: &id006 !ruby/object:Gem::Requirement
111
+ none: false
112
+ requirements:
113
+ - - ">="
114
+ - !ruby/object:Gem::Version
115
+ hash: 3
116
+ segments:
117
+ - 0
118
+ segments_generated: true
119
+ version: "0"
120
+ requirement: *id006
121
+ description: Ruby Gem for connecting to the Whiplash Merchandising API
122
+ email: mark@sitesteaders.com
123
+ executables: []
124
+
125
+ extensions: []
126
+
127
+ extra_rdoc_files:
128
+ - LICENSE.txt
129
+ - README.rdoc
130
+ files:
131
+ - lib/whiplash_api.rb
132
+ - lib/whiplash_api/base.rb
133
+ - lib/whiplash_api/item.rb
134
+ - lib/whiplash_api/order.rb
135
+ - lib/whiplash_api/order_item.rb
136
+ - LICENSE.txt
137
+ - README.rdoc
138
+ has_rdoc: true
139
+ homepage: http://github.com/ideaoforder/whiplash_api
140
+ licenses:
141
+ - MIT
142
+ post_install_message:
143
+ rdoc_options: []
144
+
145
+ require_paths:
146
+ - lib
147
+ required_ruby_version: !ruby/object:Gem::Requirement
148
+ none: false
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ hash: 3
153
+ segments:
154
+ - 0
155
+ segments_generated: true
156
+ version: "0"
157
+ required_rubygems_version: !ruby/object:Gem::Requirement
158
+ none: false
159
+ requirements:
160
+ - - ">="
161
+ - !ruby/object:Gem::Version
162
+ hash: 3
163
+ segments:
164
+ - 0
165
+ segments_generated: true
166
+ version: "0"
167
+ requirements: []
168
+
169
+ rubyforge_project:
170
+ rubygems_version: 1.3.7
171
+ signing_key:
172
+ specification_version: 3
173
+ summary: Ruby Gem for connecting to the Whiplash Merchandising API
174
+ test_files: []
175
+