answers-ruby-client 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 (41) hide show
  1. checksums.yaml +7 -0
  2. data/.env.example +2 -0
  3. data/.gitignore +23 -0
  4. data/.rbenv-version +1 -0
  5. data/.travis.yml +3 -0
  6. data/Gemfile +5 -0
  7. data/LICENSE.txt +24 -0
  8. data/README.md +120 -0
  9. data/Rakefile +6 -0
  10. data/answers-ruby-client.gemspec +34 -0
  11. data/lib/answers-ruby-client.rb +14 -0
  12. data/lib/answers/answer.rb +40 -0
  13. data/lib/answers/base_model.rb +79 -0
  14. data/lib/answers/client.rb +111 -0
  15. data/lib/answers/error.rb +4 -0
  16. data/lib/answers/protocol.rb +40 -0
  17. data/lib/answers/question.rb +38 -0
  18. data/lib/answers/version.rb +3 -0
  19. data/spec/answer_spec.rb +115 -0
  20. data/spec/cassettes/Answers_Answer/When_API_keys_are_not_provided/DELETE_destroy/throws_an_Answers_Error.yml +97 -0
  21. data/spec/cassettes/Answers_Answer/When_API_keys_are_not_provided/GET_index/contains_objects_only_of_type_Answer_Answer.yml +90 -0
  22. data/spec/cassettes/Answers_Answer/When_API_keys_are_not_provided/GET_index/retrieves_a_list_of_Answers.yml +90 -0
  23. data/spec/cassettes/Answers_Answer/When_API_keys_are_not_provided/GET_show/retrieves_a_single_object_of_type_Answers_Answer.yml +52 -0
  24. data/spec/cassettes/Answers_Answer/When_API_keys_are_not_provided/POST_create/throws_an_Answers_Error.yml +48 -0
  25. data/spec/cassettes/Answers_Answer/When_API_keys_are_not_provided/PUT_update/throws_an_Answers_Error.yml +97 -0
  26. data/spec/cassettes/Answers_Answer/When_API_keys_are_provided/DELETE_destroy/deletes_an_Answer_Answer.yml +209 -0
  27. data/spec/cassettes/Answers_Answer/When_API_keys_are_provided/POST_create/creates_an_Answer_Answer.yml +54 -0
  28. data/spec/cassettes/Answers_Answer/When_API_keys_are_provided/PUT_update/updates_an_Answer_Answer.yml +107 -0
  29. data/spec/cassettes/Answers_Question/When_API_keys_are_not_provided/DELETE_destroy/throws_an_Answers_Error.yml +97 -0
  30. data/spec/cassettes/Answers_Question/When_API_keys_are_not_provided/GET_index/contains_objects_only_of_type_Answer_Question.yml +75 -0
  31. data/spec/cassettes/Answers_Question/When_API_keys_are_not_provided/GET_index/retrieves_a_list_of_Questions.yml +75 -0
  32. data/spec/cassettes/Answers_Question/When_API_keys_are_not_provided/GET_show/retrieves_a_single_object_of_type_Answers_Question.yml +52 -0
  33. data/spec/cassettes/Answers_Question/When_API_keys_are_not_provided/POST_create/throws_an_Answers_Error.yml +48 -0
  34. data/spec/cassettes/Answers_Question/When_API_keys_are_not_provided/PUT_update/throws_an_Answers_Error.yml +97 -0
  35. data/spec/cassettes/Answers_Question/When_API_keys_are_provided/DELETE_destroy/deletes_an_Answer_Question.yml +209 -0
  36. data/spec/cassettes/Answers_Question/When_API_keys_are_provided/POST_create/creates_an_Answer_Question.yml +54 -0
  37. data/spec/cassettes/Answers_Question/When_API_keys_are_provided/PUT_update/updates_an_Answer_Question.yml +107 -0
  38. data/spec/client_spec.rb +80 -0
  39. data/spec/question_spec.rb +124 -0
  40. data/spec/spec_helper.rb +22 -0
  41. metadata +259 -0
@@ -0,0 +1,97 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: http://localhost:1337/api/v1/questions/1
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ Content-Type:
11
+ - application/json
12
+ User-Agent:
13
+ - Faraday v0.9.0
14
+ Accept-Encoding:
15
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
16
+ Accept:
17
+ - "*/*"
18
+ response:
19
+ status:
20
+ code: 200
21
+ message: OK
22
+ headers:
23
+ X-Frame-Options:
24
+ - SAMEORIGIN
25
+ X-Xss-Protection:
26
+ - 1; mode=block
27
+ X-Content-Type-Options:
28
+ - nosniff
29
+ Content-Type:
30
+ - application/json; charset=utf-8
31
+ Etag:
32
+ - '"1e78556df4691aa7c62d8958031a0eab"'
33
+ Cache-Control:
34
+ - max-age=0, private, must-revalidate
35
+ Set-Cookie:
36
+ - request_method=GET; path=/
37
+ X-Request-Id:
38
+ - dd8594c2-6e38-4fe8-a9f7-32374da892ad
39
+ X-Runtime:
40
+ - '0.016926'
41
+ Vary:
42
+ - Accept-Encoding
43
+ Connection:
44
+ - close
45
+ Server:
46
+ - thin 1.6.2 codename Doc Brown
47
+ body:
48
+ encoding: UTF-8
49
+ string: '{"questions":[{"id":1,"created_at":"2014-07-17T17:04:45.954Z","updated_at":"2014-07-25T17:39:48.211Z","text":"new_text","url":"http://localhost:1337/questions/1"}]}'
50
+ http_version:
51
+ recorded_at: Mon, 28 Jul 2014 14:43:13 GMT
52
+ - request:
53
+ method: put
54
+ uri: http://localhost:1337/api/v1/questions/1
55
+ body:
56
+ encoding: UTF-8
57
+ string: '{"id":1,"created_at":"2014-07-17T17:04:45.954Z","updated_at":"2014-07-25T17:39:48.211Z","text":"revised"}'
58
+ headers:
59
+ Content-Type:
60
+ - application/json
61
+ User-Agent:
62
+ - Faraday v0.9.0
63
+ Accept-Encoding:
64
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
65
+ Accept:
66
+ - "*/*"
67
+ response:
68
+ status:
69
+ code: 401
70
+ message: Unauthorized
71
+ headers:
72
+ X-Frame-Options:
73
+ - SAMEORIGIN
74
+ X-Xss-Protection:
75
+ - 1; mode=block
76
+ X-Content-Type-Options:
77
+ - nosniff
78
+ Content-Type:
79
+ - application/json; charset=utf-8
80
+ Cache-Control:
81
+ - no-cache
82
+ X-Request-Id:
83
+ - 44171726-b9e7-44f3-8074-d0ef584c3529
84
+ X-Runtime:
85
+ - '0.011851'
86
+ Vary:
87
+ - Accept-Encoding
88
+ Connection:
89
+ - close
90
+ Server:
91
+ - thin 1.6.2 codename Doc Brown
92
+ body:
93
+ encoding: UTF-8
94
+ string: '{"error":"You need to sign in or sign up before continuing."}'
95
+ http_version:
96
+ recorded_at: Mon, 28 Jul 2014 14:43:13 GMT
97
+ recorded_with: VCR 2.9.2
@@ -0,0 +1,209 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: http://localhost:1337/api/v1/questions
6
+ body:
7
+ encoding: UTF-8
8
+ string: '{"text":"sample","in_language":"english"}'
9
+ headers:
10
+ Content-Type:
11
+ - application/json
12
+ X-User-Email:
13
+ - alan.delevie@gsa.gov
14
+ X-User-Token:
15
+ - 1EZGWhkmhRz6DYDmEePc
16
+ User-Agent:
17
+ - Faraday v0.9.0
18
+ Accept-Encoding:
19
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
20
+ Accept:
21
+ - "*/*"
22
+ response:
23
+ status:
24
+ code: 200
25
+ message: OK
26
+ headers:
27
+ X-Frame-Options:
28
+ - SAMEORIGIN
29
+ X-Xss-Protection:
30
+ - 1; mode=block
31
+ X-Content-Type-Options:
32
+ - nosniff
33
+ Content-Type:
34
+ - application/json; charset=utf-8
35
+ Etag:
36
+ - '"71130750086a92ae2a6638dcd62de256"'
37
+ Cache-Control:
38
+ - max-age=0, private, must-revalidate
39
+ X-Request-Id:
40
+ - 64a36a24-8f0c-474c-a04f-f6a9117c040a
41
+ X-Runtime:
42
+ - '0.026691'
43
+ Vary:
44
+ - Accept-Encoding
45
+ Connection:
46
+ - close
47
+ Server:
48
+ - thin 1.6.2 codename Doc Brown
49
+ body:
50
+ encoding: UTF-8
51
+ string: '{"questions":[{"id":167,"created_at":"2014-07-28T14:43:13.982Z","updated_at":"2014-07-28T14:43:13.982Z","text":"sample","url":"http://localhost:1337/questions/167"}]}'
52
+ http_version:
53
+ recorded_at: Mon, 28 Jul 2014 14:43:13 GMT
54
+ - request:
55
+ method: get
56
+ uri: http://localhost:1337/api/v1/questions/167
57
+ body:
58
+ encoding: US-ASCII
59
+ string: ''
60
+ headers:
61
+ Content-Type:
62
+ - application/json
63
+ X-User-Email:
64
+ - alan.delevie@gsa.gov
65
+ X-User-Token:
66
+ - 1EZGWhkmhRz6DYDmEePc
67
+ User-Agent:
68
+ - Faraday v0.9.0
69
+ Accept-Encoding:
70
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
71
+ Accept:
72
+ - "*/*"
73
+ response:
74
+ status:
75
+ code: 200
76
+ message: OK
77
+ headers:
78
+ X-Frame-Options:
79
+ - SAMEORIGIN
80
+ X-Xss-Protection:
81
+ - 1; mode=block
82
+ X-Content-Type-Options:
83
+ - nosniff
84
+ Content-Type:
85
+ - application/json; charset=utf-8
86
+ Etag:
87
+ - '"71130750086a92ae2a6638dcd62de256"'
88
+ Cache-Control:
89
+ - max-age=0, private, must-revalidate
90
+ Set-Cookie:
91
+ - request_method=GET; path=/
92
+ X-Request-Id:
93
+ - 4ab42a72-f9ca-4485-b469-61bd4b5dff8e
94
+ X-Runtime:
95
+ - '0.017664'
96
+ Vary:
97
+ - Accept-Encoding
98
+ Connection:
99
+ - close
100
+ Server:
101
+ - thin 1.6.2 codename Doc Brown
102
+ body:
103
+ encoding: UTF-8
104
+ string: '{"questions":[{"id":167,"created_at":"2014-07-28T14:43:13.982Z","updated_at":"2014-07-28T14:43:13.982Z","text":"sample","url":"http://localhost:1337/questions/167"}]}'
105
+ http_version:
106
+ recorded_at: Mon, 28 Jul 2014 14:43:14 GMT
107
+ - request:
108
+ method: delete
109
+ uri: http://localhost:1337/api/v1/questions/167
110
+ body:
111
+ encoding: US-ASCII
112
+ string: ''
113
+ headers:
114
+ Content-Type:
115
+ - application/json
116
+ X-User-Email:
117
+ - alan.delevie@gsa.gov
118
+ X-User-Token:
119
+ - 1EZGWhkmhRz6DYDmEePc
120
+ User-Agent:
121
+ - Faraday v0.9.0
122
+ Accept-Encoding:
123
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
124
+ Accept:
125
+ - "*/*"
126
+ response:
127
+ status:
128
+ code: 200
129
+ message: OK
130
+ headers:
131
+ X-Frame-Options:
132
+ - SAMEORIGIN
133
+ X-Xss-Protection:
134
+ - 1; mode=block
135
+ X-Content-Type-Options:
136
+ - nosniff
137
+ Content-Type:
138
+ - application/json; charset=utf-8
139
+ Etag:
140
+ - '"71130750086a92ae2a6638dcd62de256"'
141
+ Cache-Control:
142
+ - max-age=0, private, must-revalidate
143
+ X-Request-Id:
144
+ - 4573526f-f28d-4472-88fe-77230ebed4ea
145
+ X-Runtime:
146
+ - '0.023708'
147
+ Vary:
148
+ - Accept-Encoding
149
+ Connection:
150
+ - close
151
+ Server:
152
+ - thin 1.6.2 codename Doc Brown
153
+ body:
154
+ encoding: UTF-8
155
+ string: '{"questions":[{"id":167,"created_at":"2014-07-28T14:43:13.982Z","updated_at":"2014-07-28T14:43:13.982Z","text":"sample","url":"http://localhost:1337/questions/167"}]}'
156
+ http_version:
157
+ recorded_at: Mon, 28 Jul 2014 14:43:14 GMT
158
+ - request:
159
+ method: get
160
+ uri: http://localhost:1337/api/v1/questions/167
161
+ body:
162
+ encoding: US-ASCII
163
+ string: ''
164
+ headers:
165
+ Content-Type:
166
+ - application/json
167
+ X-User-Email:
168
+ - alan.delevie@gsa.gov
169
+ X-User-Token:
170
+ - 1EZGWhkmhRz6DYDmEePc
171
+ User-Agent:
172
+ - Faraday v0.9.0
173
+ Accept-Encoding:
174
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
175
+ Accept:
176
+ - "*/*"
177
+ response:
178
+ status:
179
+ code: 404
180
+ message: Not Found
181
+ headers:
182
+ X-Frame-Options:
183
+ - SAMEORIGIN
184
+ X-Xss-Protection:
185
+ - 1; mode=block
186
+ X-Content-Type-Options:
187
+ - nosniff
188
+ Content-Type:
189
+ - application/json; charset=utf-8
190
+ Cache-Control:
191
+ - no-cache
192
+ Set-Cookie:
193
+ - request_method=GET; path=/
194
+ X-Request-Id:
195
+ - 2b7401d9-0f40-443c-bb75-cb1fefa051d8
196
+ X-Runtime:
197
+ - '0.011224'
198
+ Vary:
199
+ - Accept-Encoding
200
+ Connection:
201
+ - close
202
+ Server:
203
+ - thin 1.6.2 codename Doc Brown
204
+ body:
205
+ encoding: UTF-8
206
+ string: '{"message":"404 Not Found","status":404}'
207
+ http_version:
208
+ recorded_at: Mon, 28 Jul 2014 14:43:14 GMT
209
+ recorded_with: VCR 2.9.2
@@ -0,0 +1,54 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: http://localhost:1337/api/v1/questions
6
+ body:
7
+ encoding: UTF-8
8
+ string: '{"text":"sample","in_language":"english"}'
9
+ headers:
10
+ Content-Type:
11
+ - application/json
12
+ X-User-Email:
13
+ - alan.delevie@gsa.gov
14
+ X-User-Token:
15
+ - 1EZGWhkmhRz6DYDmEePc
16
+ User-Agent:
17
+ - Faraday v0.9.0
18
+ Accept-Encoding:
19
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
20
+ Accept:
21
+ - "*/*"
22
+ response:
23
+ status:
24
+ code: 200
25
+ message: OK
26
+ headers:
27
+ X-Frame-Options:
28
+ - SAMEORIGIN
29
+ X-Xss-Protection:
30
+ - 1; mode=block
31
+ X-Content-Type-Options:
32
+ - nosniff
33
+ Content-Type:
34
+ - application/json; charset=utf-8
35
+ Etag:
36
+ - '"b514a605de24ed0662b001227143f0b4"'
37
+ Cache-Control:
38
+ - max-age=0, private, must-revalidate
39
+ X-Request-Id:
40
+ - f63542dc-db0f-4132-badc-596dff84b7af
41
+ X-Runtime:
42
+ - '0.025952'
43
+ Vary:
44
+ - Accept-Encoding
45
+ Connection:
46
+ - close
47
+ Server:
48
+ - thin 1.6.2 codename Doc Brown
49
+ body:
50
+ encoding: UTF-8
51
+ string: '{"questions":[{"id":166,"created_at":"2014-07-28T14:43:13.919Z","updated_at":"2014-07-28T14:43:13.919Z","text":"sample","url":"http://localhost:1337/questions/166"}]}'
52
+ http_version:
53
+ recorded_at: Mon, 28 Jul 2014 14:43:13 GMT
54
+ recorded_with: VCR 2.9.2
@@ -0,0 +1,107 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: http://localhost:1337/api/v1/questions/1
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ Content-Type:
11
+ - application/json
12
+ X-User-Email:
13
+ - alan.delevie@gsa.gov
14
+ X-User-Token:
15
+ - 1EZGWhkmhRz6DYDmEePc
16
+ User-Agent:
17
+ - Faraday v0.9.0
18
+ Accept-Encoding:
19
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
20
+ Accept:
21
+ - "*/*"
22
+ response:
23
+ status:
24
+ code: 200
25
+ message: OK
26
+ headers:
27
+ X-Frame-Options:
28
+ - SAMEORIGIN
29
+ X-Xss-Protection:
30
+ - 1; mode=block
31
+ X-Content-Type-Options:
32
+ - nosniff
33
+ Content-Type:
34
+ - application/json; charset=utf-8
35
+ Etag:
36
+ - '"1e78556df4691aa7c62d8958031a0eab"'
37
+ Cache-Control:
38
+ - max-age=0, private, must-revalidate
39
+ Set-Cookie:
40
+ - request_method=GET; path=/
41
+ X-Request-Id:
42
+ - ba0e7e3f-95ab-413a-92ea-441d512c38bb
43
+ X-Runtime:
44
+ - '0.017174'
45
+ Vary:
46
+ - Accept-Encoding
47
+ Connection:
48
+ - close
49
+ Server:
50
+ - thin 1.6.2 codename Doc Brown
51
+ body:
52
+ encoding: UTF-8
53
+ string: '{"questions":[{"id":1,"created_at":"2014-07-17T17:04:45.954Z","updated_at":"2014-07-25T17:39:48.211Z","text":"new_text","url":"http://localhost:1337/questions/1"}]}'
54
+ http_version:
55
+ recorded_at: Mon, 28 Jul 2014 14:43:13 GMT
56
+ - request:
57
+ method: put
58
+ uri: http://localhost:1337/api/v1/questions/1
59
+ body:
60
+ encoding: UTF-8
61
+ string: '{"id":1,"created_at":"2014-07-17T17:04:45.954Z","updated_at":"2014-07-25T17:39:48.211Z","text":"new_text"}'
62
+ headers:
63
+ Content-Type:
64
+ - application/json
65
+ X-User-Email:
66
+ - alan.delevie@gsa.gov
67
+ X-User-Token:
68
+ - 1EZGWhkmhRz6DYDmEePc
69
+ User-Agent:
70
+ - Faraday v0.9.0
71
+ Accept-Encoding:
72
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
73
+ Accept:
74
+ - "*/*"
75
+ response:
76
+ status:
77
+ code: 200
78
+ message: OK
79
+ headers:
80
+ X-Frame-Options:
81
+ - SAMEORIGIN
82
+ X-Xss-Protection:
83
+ - 1; mode=block
84
+ X-Content-Type-Options:
85
+ - nosniff
86
+ Content-Type:
87
+ - application/json; charset=utf-8
88
+ Etag:
89
+ - '"1e78556df4691aa7c62d8958031a0eab"'
90
+ Cache-Control:
91
+ - max-age=0, private, must-revalidate
92
+ X-Request-Id:
93
+ - 8a915ffe-ffd3-4d15-a443-e91f75fc0585
94
+ X-Runtime:
95
+ - '0.024243'
96
+ Vary:
97
+ - Accept-Encoding
98
+ Connection:
99
+ - close
100
+ Server:
101
+ - thin 1.6.2 codename Doc Brown
102
+ body:
103
+ encoding: UTF-8
104
+ string: '{"questions":[{"id":1,"created_at":"2014-07-17T17:04:45.954Z","updated_at":"2014-07-25T17:39:48.211Z","text":"new_text","url":"http://localhost:1337/questions/1"}]}'
105
+ http_version:
106
+ recorded_at: Mon, 28 Jul 2014 14:43:47 GMT
107
+ recorded_with: VCR 2.9.2