answers-ruby-client 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
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,52 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: http://localhost:1337/api/v1/answers/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
+ - '"16891a972266d98b659eef6fcd1c3cc2"'
33
+ Cache-Control:
34
+ - max-age=0, private, must-revalidate
35
+ Set-Cookie:
36
+ - request_method=GET; path=/
37
+ X-Request-Id:
38
+ - 47e3ad04-57fe-4878-905f-636e472097c8
39
+ X-Runtime:
40
+ - '0.017818'
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: '{"answers":[{"id":1,"created_at":"2014-07-17T17:05:22.757Z","updated_at":"2014-07-25T17:40:55.377Z","text":"new_text","url":"http://localhost:1337/answers/1"}]}'
50
+ http_version:
51
+ recorded_at: Mon, 28 Jul 2014 14:43:13 GMT
52
+ recorded_with: VCR 2.9.2
@@ -0,0 +1,48 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: http://localhost:1337/api/v1/answers
6
+ body:
7
+ encoding: UTF-8
8
+ string: '{"text":"sample","in_language":"english"}'
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: 401
21
+ message: Unauthorized
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
+ Cache-Control:
32
+ - no-cache
33
+ X-Request-Id:
34
+ - b13e0db7-3b8a-44db-8712-3365ec1d642b
35
+ X-Runtime:
36
+ - '0.013001'
37
+ Vary:
38
+ - Accept-Encoding
39
+ Connection:
40
+ - close
41
+ Server:
42
+ - thin 1.6.2 codename Doc Brown
43
+ body:
44
+ encoding: UTF-8
45
+ string: '{"error":"You need to sign in or sign up before continuing."}'
46
+ http_version:
47
+ recorded_at: Mon, 28 Jul 2014 14:43:13 GMT
48
+ recorded_with: VCR 2.9.2
@@ -0,0 +1,97 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: http://localhost:1337/api/v1/answers/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
+ - '"16891a972266d98b659eef6fcd1c3cc2"'
33
+ Cache-Control:
34
+ - max-age=0, private, must-revalidate
35
+ Set-Cookie:
36
+ - request_method=GET; path=/
37
+ X-Request-Id:
38
+ - 6675bd21-f6e8-45f3-beaa-22d52761c5b4
39
+ X-Runtime:
40
+ - '0.017494'
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: '{"answers":[{"id":1,"created_at":"2014-07-17T17:05:22.757Z","updated_at":"2014-07-25T17:40:55.377Z","text":"new_text","url":"http://localhost:1337/answers/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/answers/1
55
+ body:
56
+ encoding: UTF-8
57
+ string: '{"id":1,"created_at":"2014-07-17T17:05:22.757Z","updated_at":"2014-07-25T17:40:55.377Z","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
+ - e986c753-e97c-488e-a883-8f66972cf68f
84
+ X-Runtime:
85
+ - '0.012730'
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/answers
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
+ - '"841745a7886d31bcc47e983533382d0e"'
37
+ Cache-Control:
38
+ - max-age=0, private, must-revalidate
39
+ X-Request-Id:
40
+ - 8c95effc-85cf-4e68-b9eb-f0e2b21541ac
41
+ X-Runtime:
42
+ - '0.023523'
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: '{"answers":[{"id":109,"created_at":"2014-07-28T14:43:13.405Z","updated_at":"2014-07-28T14:43:13.405Z","text":"sample","url":"http://localhost:1337/answers/109"}]}'
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/answers/109
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
+ - '"841745a7886d31bcc47e983533382d0e"'
88
+ Cache-Control:
89
+ - max-age=0, private, must-revalidate
90
+ Set-Cookie:
91
+ - request_method=GET; path=/
92
+ X-Request-Id:
93
+ - 1a5bd2e6-c677-43a7-98e1-e12196e9531b
94
+ X-Runtime:
95
+ - '0.017554'
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: '{"answers":[{"id":109,"created_at":"2014-07-28T14:43:13.405Z","updated_at":"2014-07-28T14:43:13.405Z","text":"sample","url":"http://localhost:1337/answers/109"}]}'
105
+ http_version:
106
+ recorded_at: Mon, 28 Jul 2014 14:43:13 GMT
107
+ - request:
108
+ method: delete
109
+ uri: http://localhost:1337/api/v1/answers/109
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
+ - '"841745a7886d31bcc47e983533382d0e"'
141
+ Cache-Control:
142
+ - max-age=0, private, must-revalidate
143
+ X-Request-Id:
144
+ - 3376fd0b-1a7e-4938-b143-ab9a33504908
145
+ X-Runtime:
146
+ - '0.023677'
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: '{"answers":[{"id":109,"created_at":"2014-07-28T14:43:13.405Z","updated_at":"2014-07-28T14:43:13.405Z","text":"sample","url":"http://localhost:1337/answers/109"}]}'
156
+ http_version:
157
+ recorded_at: Mon, 28 Jul 2014 14:43:13 GMT
158
+ - request:
159
+ method: get
160
+ uri: http://localhost:1337/api/v1/answers/109
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
+ - bf9d94c7-40cf-49d6-b495-8c7895b0b4a4
196
+ X-Runtime:
197
+ - '0.011265'
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:13 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/answers
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
+ - '"6261b9d9fe696a50b9b36a429346a7f6"'
37
+ Cache-Control:
38
+ - max-age=0, private, must-revalidate
39
+ X-Request-Id:
40
+ - 91450140-ef1b-4aa4-aeae-708328562de8
41
+ X-Runtime:
42
+ - '0.024053'
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: '{"answers":[{"id":108,"created_at":"2014-07-28T14:43:13.348Z","updated_at":"2014-07-28T14:43:13.348Z","text":"sample","url":"http://localhost:1337/answers/108"}]}'
52
+ http_version:
53
+ recorded_at: Mon, 28 Jul 2014 14:43:13 GMT
54
+ recorded_with: VCR 2.9.2