big-door-fork 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. data/.bundle/config +2 -0
  2. data/.document +5 -0
  3. data/.gitignore +22 -0
  4. data/Gemfile +12 -0
  5. data/LICENSE +20 -0
  6. data/README.rdoc +17 -0
  7. data/Rakefile +60 -0
  8. data/VERSION +1 -0
  9. data/big-door-fork.gemspec +101 -0
  10. data/features/big-door.feature +34 -0
  11. data/features/step_definitions/big-door_steps.rb +83 -0
  12. data/features/support/env.rb +5 -0
  13. data/lib/big-door.rb +153 -0
  14. data/lib/big-door/base.rb +45 -0
  15. data/lib/big-door/currency.rb +25 -0
  16. data/lib/big-door/named_award.rb +25 -0
  17. data/lib/big-door/named_award_collection.rb +27 -0
  18. data/lib/big-door/named_level.rb +25 -0
  19. data/lib/big-door/named_level_collection.rb +27 -0
  20. data/lib/big-door/named_transaction.rb +25 -0
  21. data/lib/big-door/named_transaction_group.rb +27 -0
  22. data/lib/big-door/request.rb +7 -0
  23. data/lib/big-door/response_codes.rb +266 -0
  24. data/lib/big-door/user.rb +69 -0
  25. data/spec/.rspec +1 -0
  26. data/spec/big-door_spec.rb +127 -0
  27. data/spec/spec_helper.rb +19 -0
  28. data/spec/support/vcr.rb +7 -0
  29. data/vcr_cassettes/NamedTransaction/NamedTransaction.yml +213 -0
  30. data/vcr_cassettes/NamedTransaction/specific.yml +6043 -0
  31. data/vcr_cassettes/award/award_summary.yml +34 -0
  32. data/vcr_cassettes/currency/currency.yml +52 -0
  33. data/vcr_cassettes/currency/currency_type.yml +31 -0
  34. data/vcr_cassettes/currency/specific.yml +2980 -0
  35. data/vcr_cassettes/good/good_summary.yml +34 -0
  36. data/vcr_cassettes/level/level_summary.yml +34 -0
  37. data/vcr_cassettes/named_transaction/named_transactions.yml +107 -0
  38. data/vcr_cassettes/named_transaction_group/all.yml +145 -0
  39. data/vcr_cassettes/named_transaction_group/specific.yml +3171 -0
  40. data/vcr_cassettes/user/add_points.yml +36 -0
  41. data/vcr_cassettes/user/all.yml +10035 -0
  42. data/vcr_cassettes/user/create.yml +4259 -0
  43. data/vcr_cassettes/user/currency_balance.yml +738 -0
  44. data/vcr_cassettes/user/delete.yml +28 -0
  45. data/vcr_cassettes/user/new.yml +5660 -0
  46. data/vcr_cassettes/user/new_currency_balance.yml +470 -0
  47. data/vcr_cassettes/user/specific.yml +44 -0
  48. metadata +182 -0
@@ -0,0 +1,45 @@
1
+ module BigDoor
2
+ class Base
3
+ include ClassMethods
4
+
5
+ def initialize(*args)
6
+ options = args.last
7
+ ClassMethods.module_eval do
8
+ instance_variable_set('@app_key', options[:app_key])
9
+ end
10
+ ClassMethods.module_eval do
11
+ instance_variable_set('@secret_key', options[:secret_key])
12
+ end
13
+ end
14
+
15
+ # def get_award_summary
16
+ # perform_get('award_summary')
17
+ # end
18
+ #
19
+ # def get_transaction_summary
20
+ # perform_get('transaction_summary')
21
+ # end
22
+ #
23
+ # def get_level_summary
24
+ # perform_get('level_summary')
25
+ # end
26
+ #
27
+ # def get_good_summary
28
+ # perform_get('good_summary')
29
+ # end
30
+ #
31
+ # def get_currency_type
32
+ # perform_get('currency_type')
33
+ # end
34
+ #
35
+ # def get_currency
36
+ # perform_get('currency')
37
+ # end
38
+
39
+ def method_missing(name, *args)
40
+ name, request_type, method_name = name.to_s.match(/(put|post|get|delete)_(.+)/).to_a
41
+ super(name, args) if name.nil? or request_type.nil? or method_name.nil?
42
+ perform_request request_type, method_name, args.first
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,25 @@
1
+ module BigDoor
2
+ class Currency
3
+ include ClassMethods
4
+
5
+ def initialize(params)
6
+ params.each_pair do |key, val|
7
+ self.class.class_eval do
8
+ # overwrite the .id method and all others
9
+ self.instance_eval do
10
+ attr_accessor key
11
+ end
12
+ end
13
+ instance_variable_set("@#{key}", val)
14
+ end
15
+ end
16
+
17
+ def self.all
18
+ perform_request('get', 'currency')
19
+ end
20
+
21
+ def self.find(params={})
22
+ perform_request('get', 'currency', params)
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,25 @@
1
+ module BigDoor
2
+ class NamedAward
3
+ include ClassMethods
4
+
5
+ def initialize(params)
6
+ params.each_pair do |key, val|
7
+ self.class.class_eval do
8
+ next if self.instance_methods.include?(key)
9
+ self.instance_eval do
10
+ attr_accessor key
11
+ end
12
+ end
13
+ instance_variable_set("@#{key}", val)
14
+ end
15
+ end
16
+
17
+ def self.all
18
+ perform_request('get', 'named_award')
19
+ end
20
+
21
+ def self.find(params={})
22
+ results = perform_request('get', 'named_award', params)
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,27 @@
1
+ module BigDoor
2
+ class NamedAwardCollection
3
+ include ClassMethods
4
+
5
+ def initialize(params)
6
+ params.each_pair do |key, val|
7
+ self.class.class_eval do
8
+ next if self.instance_methods.include?(key) and key.to_s != 'id'
9
+ self.instance_eval do
10
+ attr_accessor key
11
+ end
12
+ end
13
+ instance_variable_set("@#{key}", val)
14
+ end
15
+
16
+ self.named_awards = parse_out_classes(params['named_awards'])
17
+ end
18
+
19
+ def self.all
20
+ perform_request('get', 'named_award_collection')
21
+ end
22
+
23
+ def self.find(params={})
24
+ results = perform_request('get', 'named_award_collection', params)
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,25 @@
1
+ module BigDoor
2
+ class NamedLevel
3
+ include ClassMethods
4
+
5
+ def initialize(params)
6
+ params.each_pair do |key, val|
7
+ self.class.class_eval do
8
+ next if self.instance_methods.include?(key)
9
+ self.instance_eval do
10
+ attr_accessor key
11
+ end
12
+ end
13
+ instance_variable_set("@#{key}", val)
14
+ end
15
+ end
16
+
17
+ def self.all
18
+ perform_request('get', 'named_level')
19
+ end
20
+
21
+ def self.find(params={})
22
+ results = perform_request('get', 'named_level', params)
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,27 @@
1
+ module BigDoor
2
+ class NamedLevelCollection
3
+ include ClassMethods
4
+
5
+ def initialize(params)
6
+ params.each_pair do |key, val|
7
+ self.class.class_eval do
8
+ next if self.instance_methods.include?(key) and key.to_s != 'id'
9
+ self.instance_eval do
10
+ attr_accessor key
11
+ end
12
+ end
13
+ instance_variable_set("@#{key}", val)
14
+ end
15
+
16
+ self.named_levels = parse_out_classes(params['named_levels'])
17
+ end
18
+
19
+ def self.all
20
+ perform_request('get', 'named_level_collection')
21
+ end
22
+
23
+ def self.find(params={})
24
+ results = perform_request('get', 'named_level_collection', params)
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,25 @@
1
+ module BigDoor
2
+ class NamedTransaction
3
+ include ClassMethods
4
+
5
+ def initialize(params)
6
+ params.each_pair do |key, val|
7
+ self.class.class_eval do
8
+ next if self.instance_methods.include?(key)
9
+ self.instance_eval do
10
+ attr_accessor key
11
+ end
12
+ end
13
+ instance_variable_set("@#{key}", val)
14
+ end
15
+ end
16
+
17
+ def self.all
18
+ perform_request('get', 'named_transaction')
19
+ end
20
+
21
+ def self.find(params={})
22
+ results = perform_request('get', 'named_transaction', params)
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,27 @@
1
+ module BigDoor
2
+ class NamedTransactionGroup
3
+ include ClassMethods
4
+
5
+ def initialize(params)
6
+ params.each_pair do |key, val|
7
+ self.class.class_eval do
8
+ next if self.instance_methods.include?(key) and key.to_s != 'id'
9
+ self.instance_eval do
10
+ attr_accessor key
11
+ end
12
+ end
13
+ instance_variable_set("@#{key}", val)
14
+ end
15
+
16
+ self.named_transactions = parse_out_classes(params['named_transactions'])
17
+ end
18
+
19
+ def self.all
20
+ perform_request('get', 'named_transaction_group')
21
+ end
22
+
23
+ def self.find(params={})
24
+ results = perform_request('get', 'named_transaction_group', params)
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,7 @@
1
+ module BigDoor
2
+ class Request
3
+ include HTTParty
4
+
5
+ format :json
6
+ end
7
+ end
@@ -0,0 +1,266 @@
1
+ module BigDoor
2
+ module ResponseCodes
3
+
4
+ def self.find(args)
5
+ if args.is_a? Numeric
6
+ args = {:code => args}
7
+ end
8
+ raise ArgumentError, "Expected a Hash but got a #{args.class}" unless args.is_a? Hash
9
+ CODES.find {|x| x[args.keys.first.to_sym] == args.values.first}
10
+ end
11
+
12
+ CODES = [
13
+ {:code => 0,
14
+ :response_condition => "Created",
15
+ :log => false,
16
+ :is_error => false,
17
+ :return_objects_url_with_error => false,
18
+ :http_response => 201,
19
+ :http_code_definition => "Created",
20
+ :reason_phrase => "Created",
21
+ :header_modifications => "",
22
+ :value => ""},
23
+ {:code => 1,
24
+ :response_condition => "Updated",
25
+ :log => false,
26
+ :is_error => false,
27
+ :return_objects_url_with_error => false,
28
+ :http_response => 200,
29
+ :http_code_definition => "OK",
30
+ :reason_phrase => "Updated",
31
+ :header_modifications => "",
32
+ :value => ""},
33
+ {:code => 2,
34
+ :response_condition => "Signature Failure Error",
35
+ :log => true,
36
+ :is_error => true,
37
+ :return_objects_url_with_error => false,
38
+ :http_response => 401,
39
+ :http_code_definition => "Unauthorized",
40
+ :reason_phrase => "Invalid signature; review the Request Signature process and retry",
41
+ :header_modifications => "WWW-Authenticate",
42
+ :value => "auth-scheme = \"Digest\" nonce = \"random number\""},
43
+ {:code => 3,
44
+ :response_condition => "User Cap Error",
45
+ :log => true,
46
+ :is_error => true,
47
+ :return_objects_url_with_error => true,
48
+ :http_response => 503,
49
+ :http_code_definition => "Service Unavailable",
50
+ :reason_phrase => "User Cap met; if applicable,
51
+ wait and retry or re-configure caps.",
52
+ :header_modifications => "",
53
+ :value => ""},
54
+ {:code => 4,
55
+ :response_condition => "Replay (pre) Error",
56
+ :log => true,
57
+ :is_error => true,
58
+ :return_objects_url_with_error => true,
59
+ :http_response => 503,
60
+ :http_code_definition => "Service Unavailable",
61
+ :reason_phrase => "Token previously used (pre); use a unique token",
62
+ :header_modifications => "",
63
+ :value => ""},
64
+ {:code => 5,
65
+ :response_condition => "No Named Group Primary Error",
66
+ :log => true,
67
+ :is_error => true,
68
+ :return_objects_url_with_error => true,
69
+ :http_response => 409,
70
+ :http_code_definition => "Conflict",
71
+ :reason_phrase => "No Named Group Primary; set a Primary Named Transaction for this group.",
72
+ :header_modifications => "",
73
+ :value => ""},
74
+ {:code => 6,
75
+ :response_condition => "Variable Amounts Disallowed Error [2]",
76
+ :log => false,
77
+ :is_error => true,
78
+ :return_objects_url_with_error => true,
79
+ :http_response => 409,
80
+ :http_code_definition => "Conflict",
81
+ :reason_phrase => "Variable amounts not allowed; retry without passing amount,
82
+ or reconfigure group.",
83
+ :header_modifications => "",
84
+ :value => ""},
85
+ {:code => 7,
86
+ :response_condition => "Balance Exceeded Error",
87
+ :log => true,
88
+ :is_error => true,
89
+ :return_objects_url_with_error => true,
90
+ :http_response => 402,
91
+ :http_code_definition => "Payment Required",
92
+ :reason_phrase => "Balance exceeded for this user; advise end-user",
93
+ :header_modifications => "",
94
+ :value => ""},
95
+ {:code => 8,
96
+ :response_condition => "Transaction Error",
97
+ :log => true,
98
+ :is_error => true,
99
+ :return_objects_url_with_error => true,
100
+ :http_response => 500,
101
+ :http_code_definition => "Internal Server Error",
102
+ :reason_phrase => "Transaction error; alert service provider",
103
+ :header_modifications => "",
104
+ :value => ""},
105
+ {:code => 9,
106
+ :response_condition => "Summary Update Error [3]",
107
+ :log => false,
108
+ :is_error => true,
109
+ :return_objects_url_with_error => true,
110
+ :http_response => 500,
111
+ :http_code_definition => "Internal Server Error",
112
+ :reason_phrase => "Summary update error; alert service provider",
113
+ :header_modifications => "",
114
+ :value => ""},
115
+ {:code => 10,
116
+ :response_condition => "Replay (post) Error",
117
+ :log => true,
118
+ :is_error => true,
119
+ :return_objects_url_with_error => true,
120
+ :http_response => 503,
121
+ :http_code_definition => "Service Unavailable",
122
+ :reason_phrase => "Token previously used (post); use a unique token",
123
+ :header_modifications => "",
124
+ :value => ""},
125
+ {:code => 11,
126
+ :response_condition => "Method Not Allowed",
127
+ :log => true,
128
+ :is_error => true,
129
+ :return_objects_url_with_error => false,
130
+ :http_response => 405,
131
+ :http_code_definition => "Method Not Allowed",
132
+ :reason_phrase => "HTTP Method not allowed on this resource",
133
+ :header_modifications => "",
134
+ :value => ""},
135
+ {:code => 12,
136
+ :response_condition => "Method Not Recognized",
137
+ :log => true,
138
+ :is_error => true,
139
+ :return_objects_url_with_error => false,
140
+ :http_response => 501,
141
+ :http_code_definition => "Not Implemented",
142
+ :reason_phrase => "HTTP Method not recognized.",
143
+ :header_modifications => "",
144
+ :value => ""},
145
+ {:code => 13,
146
+ :response_condition => "User Disabled",
147
+ :log => true,
148
+ :is_error => true,
149
+ :return_objects_url_with_error => true,
150
+ :http_response => 403,
151
+ :http_code_definition => "Forbidden",
152
+ :reason_phrase => "User has been disabled; contact us to re-enable",
153
+ :header_modifications => "",
154
+ :value => ""},
155
+ {:code => 14,
156
+ :response_condition => "Named Transaction is_source misconfigured",
157
+ :log => true,
158
+ :is_error => true,
159
+ :return_objects_url_with_error => true,
160
+ :http_response => 409,
161
+ :http_code_definition => "Conflict",
162
+ :reason_phrase => "Named Transaction has incorrect is_source flag. Sales of goods must not be sources",
163
+ :header_modifications => "",
164
+ :value => ""},
165
+ {:code => 15,
166
+ :response_condition => "Missing Argument",
167
+ :log => true,
168
+ :is_error => true,
169
+ :return_objects_url_with_error => false,
170
+ :http_response => 405,
171
+ :http_code_definition => "Method Not Allowed",
172
+ :reason_phrase => "HTTP Method not allowed because it was missing a required argument",
173
+ :header_modifications => "",
174
+ :value => ""},
175
+ {:code => 16,
176
+ :response_condition => "Invalid ID or value in GET",
177
+ :log => true,
178
+ :is_error => true,
179
+ :return_objects_url_with_error => false,
180
+ :http_response => 405,
181
+ :http_code_definition => "Method Not Allowed",
182
+ :reason_phrase => "HTTP Method not allowed because it attempted to use a not owned or otherwise invalid resource.",
183
+ :header_modifications => "",
184
+ :value => ""},
185
+ {:code => 17,
186
+ :response_condition => "Invalid ID or value in POST",
187
+ :log => true,
188
+ :is_error => true,
189
+ :return_objects_url_with_error => false,
190
+ :http_response => 405,
191
+ :http_code_definition => "Method Not Allowed",
192
+ :reason_phrase => "HTTP Method not allowed because it attempted to use a not owned or otherwise invalid resource.",
193
+ :header_modifications => "",
194
+ :value => ""},
195
+ {:code => 18,
196
+ :response_condition => "Timestamp expired",
197
+ :log => true,
198
+ :is_error => true,
199
+ :return_objects_url_with_error => false,
200
+ :http_response => 401,
201
+ :http_code_definition => "Unauthorized",
202
+ :reason_phrase => "Timestamp has expired; create a new request with a current timestamp.",
203
+ :header_modifications => "",
204
+ :value => ""},
205
+ {:code => 19,
206
+ :response_condition => "Challenge-response failure",
207
+ :log => true,
208
+ :is_error => true,
209
+ :return_objects_url_with_error => false,
210
+ :http_response => 401,
211
+ :http_code_definition => "Unauthorized",
212
+ :reason_phrase => "6 challenge response failures",
213
+ :header_modifications => "",
214
+ :value => ""},
215
+ {:code => 20,
216
+ :response_condition => "Challenge-response success",
217
+ :log => true,
218
+ :is_error => false,
219
+ :return_objects_url_with_error => false,
220
+ :http_response => 200,
221
+ :http_code_definition => "OK",
222
+ :reason_phrase => "Challenge-response accepted",
223
+ :header_modifications => "",
224
+ :value => ""},
225
+ {:code => 21,
226
+ :response_condition => "Malformed input parameter",
227
+ :log => true,
228
+ :is_error => true,
229
+ :return_objects_url_with_error => true,
230
+ :http_response => 400,
231
+ :http_code_definition => "Bad Request",
232
+ :reason_phrase => "Token must be a valid hexidecimal GUID",
233
+ :header_modifications => "",
234
+ :value => ""},
235
+ {:code => 22,
236
+ :response_condition => "Disabled Named Good Collection",
237
+ :log => true,
238
+ :is_error => true,
239
+ :return_objects_url_with_error => true,
240
+ :http_response => 409,
241
+ :http_code_definition => "Conflict",
242
+ :reason_phrase => "An associated NamedGood has been disabled via its NamedGoodCollection; contact service provider",
243
+ :header_modifications => "",
244
+ :value => ""},
245
+ {:code => 23,
246
+ :response_condition => "Disabled Named Good",
247
+ :log => true,
248
+ :is_error => true,
249
+ :return_objects_url_with_error => true,
250
+ :http_response => 409,
251
+ :http_code_definition => "Conflict",
252
+ :reason_phrase => "An associated NamedGood has been disabled; contact service provider",
253
+ :header_modifications => "",
254
+ :value => ""},
255
+ {:code => 24,
256
+ :response_condition => "Resource Found",
257
+ :log => true,
258
+ :is_error => false,
259
+ :return_objects_url_with_error => false,
260
+ :http_response => 200,
261
+ :http_code_definition => "OK",
262
+ :reason_phrase => "The resource was found. Request this resource with verbosity > 0 to retrieve data.",
263
+ :header_modifications => "",
264
+ :value => ""}]
265
+ end
266
+ end