openstax_exchange 0.0.2 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (18) hide show
  1. data/.gitignore +1 -0
  2. data/.ruby-version +1 -1
  3. data/.travis.yml +3 -1
  4. data/exchange-client.gemspec +1 -0
  5. data/lib/openstax/exchange/exchange.rb +4 -4
  6. data/lib/openstax/exchange/fake_client/fake_client.rb +11 -10
  7. data/lib/openstax/exchange/real_client/real_client.rb +14 -4
  8. data/lib/openstax/exchange/version.rb +1 -1
  9. data/spec/cassettes/OpenStax_Exchange_RealClient/behaves_like_exchange_client_api_v1/{_create_identifier → _create_identifiers}/success/creates_and_returns_a_new_identifier.yml +27 -20
  10. data/spec/cassettes/OpenStax_Exchange_RealClient/behaves_like_exchange_client_api_v1/{_create_identifier/success/creates_a_distinct_identifer_per_invokation.yml → _create_identifiers/success/creates_distinct_identifiers_per_invokation.yml} +42 -31
  11. data/spec/cassettes/OpenStax_Exchange_RealClient/behaves_like_exchange_client_api_v1/_record_multiple_choice_answer/duplicate_identifer_resource_trial_triplet/{raises_an_exception.yml → records_the_new_answer.yml} +44 -40
  12. data/spec/cassettes/OpenStax_Exchange_RealClient/behaves_like_exchange_client_api_v1/_record_multiple_choice_answer/invalid_resource_string/raises_an_exception.yml +40 -31
  13. data/spec/cassettes/OpenStax_Exchange_RealClient/behaves_like_exchange_client_api_v1/_record_multiple_choice_answer/success/allows_answers_with_distinct_identifiers_to_be_saved.yml +70 -55
  14. data/spec/cassettes/OpenStax_Exchange_RealClient/behaves_like_exchange_client_api_v1/_record_multiple_choice_answer/success/allows_answers_with_distinct_resources_to_be_saved.yml +55 -44
  15. data/spec/cassettes/OpenStax_Exchange_RealClient/behaves_like_exchange_client_api_v1/_record_multiple_choice_answer/success/allows_answers_with_distinct_trials_to_be_saved.yml +55 -44
  16. data/spec/cassettes/OpenStax_Exchange_RealClient/behaves_like_exchange_client_api_v1/_record_multiple_choice_answer/success/creates_a_multiple_choice_answer_associated_with_the_given_identifier.yml +41 -32
  17. data/spec/lib/openstax/exchange/shared_examples_for_exchange_client_v1.rb +40 -24
  18. metadata +26 -10
data/.gitignore CHANGED
@@ -13,3 +13,4 @@
13
13
  *.a
14
14
  mkmf.log
15
15
  coverage
16
+ .DS_Store
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- ruby-1.9.3-p545
1
+ 1.9.3-p545
data/.travis.yml CHANGED
@@ -1,8 +1,10 @@
1
+ sudo: false
1
2
  language: ruby
2
3
  rvm:
3
4
  - "1.9.3-p545"
5
+ cache: bundler
4
6
  install:
5
7
  - gem install bundler
6
- - bundle install
8
+ - bundle install --retry=6
7
9
  script:
8
10
  - bundle exec rake spec
@@ -19,6 +19,7 @@ Gem::Specification.new do |spec|
19
19
  spec.require_paths = ["lib"]
20
20
 
21
21
  spec.add_dependency "oauth2", ">= 0.5.0"
22
+ spec.add_dependency "hashie"
22
23
 
23
24
  spec.add_development_dependency "bundler", "~> 1.7"
24
25
  spec.add_development_dependency "rake", "~> 10.0"
@@ -27,11 +27,11 @@ module OpenStax
27
27
  !!@use_real_client
28
28
  end
29
29
 
30
- def self.create_identifier
30
+ def self.create_identifiers
31
31
  begin
32
- client.create_identifier
32
+ client.create_identifiers
33
33
  rescue StandardError => error
34
- raise ClientError.new("create_identifier failure", error)
34
+ raise ClientError.new("create_identifiers failure", error)
35
35
  end
36
36
  end
37
37
 
@@ -62,4 +62,4 @@ module OpenStax
62
62
  end
63
63
 
64
64
  end
65
- end
65
+ end
@@ -1,5 +1,6 @@
1
1
  require 'securerandom'
2
2
  require 'uri'
3
+ require 'hashie'
3
4
 
4
5
  module OpenStax
5
6
  module Exchange
@@ -42,21 +43,21 @@ module OpenStax
42
43
  @token
43
44
  end
44
45
 
45
- def create_identifier
46
- SecureRandom.hex(64)
46
+ def create_identifiers
47
+ Hashie::Mash.new(
48
+ 'read' => SecureRandom.hex(64),
49
+ 'write' => SecureRandom.hex(64)
50
+ )
47
51
  end
48
52
 
49
53
  def record_multiple_choice_answer(identifier, resource, trial, answer)
54
+ host = URI(resource).host
55
+ raise "invalid resource" unless host =~ /openstax\.org\z|localhost\z/
56
+
50
57
  @multiple_choice_responses[identifier] ||= {}
51
58
  @multiple_choice_responses[identifier][resource] ||= {}
52
-
53
- raise "invalid resource" \
54
- unless URI(resource).host == "exercises.openstax.org"
55
-
56
- raise "duplicate response for (identifier,resource,trial) triplet" \
57
- if @multiple_choice_responses[identifier][resource][trial]
58
-
59
- @multiple_choice_responses[identifier][resource][trial] = answer
59
+ @multiple_choice_responses[identifier][resource][trial] ||= []
60
+ @multiple_choice_responses[identifier][resource][trial] << answer
60
61
 
61
62
  return {
62
63
  'identifier' => identifier,
@@ -1,4 +1,5 @@
1
1
  require 'oauth2'
2
+ require 'hashie'
2
3
 
3
4
  module OpenStax
4
5
  module Exchange
@@ -28,29 +29,33 @@ module OpenStax
28
29
  @oauth_token.token
29
30
  end
30
31
 
31
- def create_identifier
32
+ def create_identifiers
32
33
  options = {}
33
34
  add_accept_header! options
35
+ add_content_type_header! options
34
36
 
35
37
  response = @oauth_token.request(
36
38
  :post,
37
39
  "#{@server_url}/api/identifiers",
38
- options)
40
+ options
41
+ )
39
42
 
40
- return JSON.parse(response.body)['identifier']
43
+ return Hashie::Mash.new(JSON.parse(response.body))
41
44
  end
42
45
 
43
46
  def record_multiple_choice_answer(identifier, resource, trial, answer)
44
47
  options = {}
45
48
  add_accept_header! options
46
49
  add_authorization_header! options
50
+ add_content_type_header! options
47
51
 
48
52
  options[:body] = { identifier: identifier, resource: resource, trial: trial, answer: answer }.to_json
49
53
 
50
54
  response = @oauth_token.request(
51
55
  :post,
52
56
  "#{@server_url}/api/events/platforms/multiple_choices",
53
- options)
57
+ options
58
+ )
54
59
 
55
60
  return JSON.parse(response.body)
56
61
  end
@@ -70,6 +75,11 @@ module OpenStax
70
75
  add_header_hash! options
71
76
  options[:headers].merge!({ 'Authorization' => "Bearer #{token}" })
72
77
  end
78
+
79
+ def add_content_type_header!(options)
80
+ add_header_hash! options
81
+ options[:headers].merge!({ 'Content-Type' => "application/json" })
82
+ end
73
83
  end
74
84
 
75
85
  end
@@ -1,5 +1,5 @@
1
1
  module OpenStax
2
2
  module Exchange
3
- VERSION = "0.0.2"
3
+ VERSION = "0.1.0"
4
4
  end
5
5
  end
@@ -4,15 +4,17 @@ http_interactions:
4
4
  method: post
5
5
  uri: http://123:abc@localhost:3003/oauth/token
6
6
  body:
7
- encoding: US-ASCII
7
+ encoding: UTF-8
8
8
  string: grant_type=client_credentials
9
9
  headers:
10
10
  User-Agent:
11
- - Faraday v0.9.0
11
+ - Faraday v0.9.1
12
12
  Content-Type:
13
13
  - application/x-www-form-urlencoded
14
+ Accept-Encoding:
15
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
14
16
  Accept:
15
- - ! '*/*'
17
+ - "*/*"
16
18
  response:
17
19
  status:
18
20
  code: 200
@@ -31,35 +33,40 @@ http_interactions:
31
33
  Content-Type:
32
34
  - application/json; charset=utf-8
33
35
  Etag:
34
- - W/"f04b2cfc92d51ad3cc0806eeea34ae39"
36
+ - W/"b8b7933dc19f52992aca234229e6ed19"
35
37
  X-Request-Id:
36
- - 0ade458e-d6b6-47ff-88af-36a192d55ed4
38
+ - c7b06596-cef0-4675-a04b-76c8e27b63db
37
39
  X-Runtime:
38
- - '0.029061'
40
+ - '0.018396'
39
41
  Connection:
40
42
  - close
41
43
  Server:
42
44
  - thin
43
45
  body:
44
- encoding: US-ASCII
45
- string: ! '{"access_token":"bcf348f1e3d1b3422422671a2c940d59351bad44b3b95ed3b2296c16f57675a2","token_type":"bearer"}'
46
+ encoding: UTF-8
47
+ string: '{"access_token":"cecb9cf0b72448771be33bea9caa9aab1cb2b0d5f6488a010dcdd0218ab811b3","token_type":"bearer","scope":"read
48
+ write","created_at":1430246609}'
46
49
  http_version:
47
- recorded_at: Mon, 12 Jan 2015 21:08:52 GMT
50
+ recorded_at: Tue, 28 Apr 2015 18:43:29 GMT
48
51
  - request:
49
52
  method: post
50
53
  uri: http://localhost:3003/api/identifiers
51
54
  body:
52
- encoding: US-ASCII
55
+ encoding: UTF-8
53
56
  string: ''
54
57
  headers:
55
58
  User-Agent:
56
- - Faraday v0.9.0
59
+ - Faraday v0.9.1
57
60
  Accept:
58
61
  - application/vnd.exchange.openstax.v1
62
+ Content-Type:
63
+ - application/json
59
64
  Authorization:
60
- - Bearer bcf348f1e3d1b3422422671a2c940d59351bad44b3b95ed3b2296c16f57675a2
65
+ - Bearer cecb9cf0b72448771be33bea9caa9aab1cb2b0d5f6488a010dcdd0218ab811b3
61
66
  Content-Length:
62
67
  - '0'
68
+ Accept-Encoding:
69
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
63
70
  response:
64
71
  status:
65
72
  code: 201
@@ -71,27 +78,27 @@ http_interactions:
71
78
  - 1; mode=block
72
79
  X-Content-Type-Options:
73
80
  - nosniff
81
+ Date:
82
+ - Tue, 28 Apr 2015 18:43:29 GMT
74
83
  Content-Type:
75
84
  - application/json; charset=utf-8
76
85
  Etag:
77
- - W/"0ca26961ce9d51f60f5a467cfe7ba4c2"
86
+ - W/"418c0e720814d0c848ca1af5ff6076b7"
78
87
  Cache-Control:
79
88
  - max-age=0, private, must-revalidate
80
89
  Set-Cookie:
81
- - _exercises_session=TnZoWHNTaWdjZmJJUXg2VHdOdERvcTA5a2R6WURqQkJub1FMYlZYdEpKZ3hCQjJiekx2ZVdDL2ZBcWMwOW53Y3lFVHYzWHJYTFlhdW02MUVKMXdZY2c9PS0tQ1VnN1EzSmxad1BjY1d5UVNHR29xdz09--e0ce290be622c8641bdc4072f45e8f23b596a233;
82
- path=/; HttpOnly
83
90
  - request_method=POST; path=/
84
91
  X-Request-Id:
85
- - 15464bd1-b133-4c40-9e36-17a4b3a43ebc
92
+ - eb06ece6-3591-43c7-a668-3dabdb54be9b
86
93
  X-Runtime:
87
- - '0.047932'
94
+ - '0.066011'
88
95
  Connection:
89
96
  - close
90
97
  Server:
91
98
  - thin
92
99
  body:
93
- encoding: US-ASCII
94
- string: ! '{"identifier":"e4b89fa467a1f56272ab3d4440cd784b9a8eaa377f55997c74a452c3e084bf69"}'
100
+ encoding: UTF-8
101
+ string: '{"read":"2f29e60deb4d57a2ffd61445bae1d16cf872a36e54261aca523afce49368b8fc","write":"2fcae26ba766d07e9567b975be1847af6e26e62f92d525cf4667d152cba10606"}'
95
102
  http_version:
96
- recorded_at: Mon, 12 Jan 2015 21:08:52 GMT
103
+ recorded_at: Tue, 28 Apr 2015 18:43:29 GMT
97
104
  recorded_with: VCR 2.9.3
@@ -4,15 +4,17 @@ http_interactions:
4
4
  method: post
5
5
  uri: http://123:abc@localhost:3003/oauth/token
6
6
  body:
7
- encoding: US-ASCII
7
+ encoding: UTF-8
8
8
  string: grant_type=client_credentials
9
9
  headers:
10
10
  User-Agent:
11
- - Faraday v0.9.0
11
+ - Faraday v0.9.1
12
12
  Content-Type:
13
13
  - application/x-www-form-urlencoded
14
+ Accept-Encoding:
15
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
14
16
  Accept:
15
- - ! '*/*'
17
+ - "*/*"
16
18
  response:
17
19
  status:
18
20
  code: 200
@@ -31,35 +33,40 @@ http_interactions:
31
33
  Content-Type:
32
34
  - application/json; charset=utf-8
33
35
  Etag:
34
- - W/"78a764ea7b6f5c5a842411f5857c9fca"
36
+ - W/"cca56781b51226d52e6540d9b764f26e"
35
37
  X-Request-Id:
36
- - 167f3bf7-4087-4a93-a227-e9402d4f10e1
38
+ - 05afba0e-565e-4f47-ac73-bbaf3ffe9fd3
37
39
  X-Runtime:
38
- - '0.014904'
40
+ - '0.016329'
39
41
  Connection:
40
42
  - close
41
43
  Server:
42
44
  - thin
43
45
  body:
44
- encoding: US-ASCII
45
- string: ! '{"access_token":"4b75ee3427beb3b486def357c3d7e6aa97ca948a8bfb7528c0a09913525795d9","token_type":"bearer"}'
46
+ encoding: UTF-8
47
+ string: '{"access_token":"bc4c6dec5fb886a92feb3cb703a4169a828b78c98a2f06704dddb77b91b72d70","token_type":"bearer","scope":"read
48
+ write","created_at":1430246609}'
46
49
  http_version:
47
- recorded_at: Mon, 12 Jan 2015 21:08:52 GMT
50
+ recorded_at: Tue, 28 Apr 2015 18:43:29 GMT
48
51
  - request:
49
52
  method: post
50
53
  uri: http://localhost:3003/api/identifiers
51
54
  body:
52
- encoding: US-ASCII
55
+ encoding: UTF-8
53
56
  string: ''
54
57
  headers:
55
58
  User-Agent:
56
- - Faraday v0.9.0
59
+ - Faraday v0.9.1
57
60
  Accept:
58
61
  - application/vnd.exchange.openstax.v1
62
+ Content-Type:
63
+ - application/json
59
64
  Authorization:
60
- - Bearer 4b75ee3427beb3b486def357c3d7e6aa97ca948a8bfb7528c0a09913525795d9
65
+ - Bearer bc4c6dec5fb886a92feb3cb703a4169a828b78c98a2f06704dddb77b91b72d70
61
66
  Content-Length:
62
67
  - '0'
68
+ Accept-Encoding:
69
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
63
70
  response:
64
71
  status:
65
72
  code: 201
@@ -71,44 +78,48 @@ http_interactions:
71
78
  - 1; mode=block
72
79
  X-Content-Type-Options:
73
80
  - nosniff
81
+ Date:
82
+ - Tue, 28 Apr 2015 18:43:29 GMT
74
83
  Content-Type:
75
84
  - application/json; charset=utf-8
76
85
  Etag:
77
- - W/"827945503ecf81b1c4c910bee932d933"
86
+ - W/"10c4bbcd785346bcbb20bc277bb8d34e"
78
87
  Cache-Control:
79
88
  - max-age=0, private, must-revalidate
80
89
  Set-Cookie:
81
- - _exercises_session=c0cyWnNJeUZSUVQ1MVJ6QUdYUjJKakNSbFRweFQwdnovVms3dm42dDRqMFdSSTJwM2dVTU5GelFPNjhSRXdRVkQxYUlNN0Jpek5Nd2RtenlkNUV0VlE9PS0tdkxMWVV4dUgvVFd3YzFTZzJkNUFXQT09--10f51958af22134ccfe27073cd381c0faf434a35;
82
- path=/; HttpOnly
83
90
  - request_method=POST; path=/
84
91
  X-Request-Id:
85
- - 4911b91c-7fb5-49ec-9f91-0772d50ef84c
92
+ - 57673f24-faab-4a70-ad84-271d78ef9e05
86
93
  X-Runtime:
87
- - '0.078438'
94
+ - '0.058148'
88
95
  Connection:
89
96
  - close
90
97
  Server:
91
98
  - thin
92
99
  body:
93
- encoding: US-ASCII
94
- string: ! '{"identifier":"d8626248d8781ea4a079810bbc2414194335fdab7658b7ba2fab8986b80b7b05"}'
100
+ encoding: UTF-8
101
+ string: '{"read":"e6bf61fd03a73703c80dda9b7080d6d6c8158c2bc189ab3943d0bde3950073b7","write":"751996e258c37c2a30e26ddf148180369012c5f6fa99b14101b3adb93ad05f29"}'
95
102
  http_version:
96
- recorded_at: Mon, 12 Jan 2015 21:08:52 GMT
103
+ recorded_at: Tue, 28 Apr 2015 18:43:29 GMT
97
104
  - request:
98
105
  method: post
99
106
  uri: http://localhost:3003/api/identifiers
100
107
  body:
101
- encoding: US-ASCII
108
+ encoding: UTF-8
102
109
  string: ''
103
110
  headers:
104
111
  User-Agent:
105
- - Faraday v0.9.0
112
+ - Faraday v0.9.1
106
113
  Accept:
107
114
  - application/vnd.exchange.openstax.v1
115
+ Content-Type:
116
+ - application/json
108
117
  Authorization:
109
- - Bearer 4b75ee3427beb3b486def357c3d7e6aa97ca948a8bfb7528c0a09913525795d9
118
+ - Bearer bc4c6dec5fb886a92feb3cb703a4169a828b78c98a2f06704dddb77b91b72d70
110
119
  Content-Length:
111
120
  - '0'
121
+ Accept-Encoding:
122
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
112
123
  response:
113
124
  status:
114
125
  code: 201
@@ -120,27 +131,27 @@ http_interactions:
120
131
  - 1; mode=block
121
132
  X-Content-Type-Options:
122
133
  - nosniff
134
+ Date:
135
+ - Tue, 28 Apr 2015 18:43:29 GMT
123
136
  Content-Type:
124
137
  - application/json; charset=utf-8
125
138
  Etag:
126
- - W/"8d46bbfacc4812d2aafea6655fc6ea42"
139
+ - W/"a191e6d531a6a3182aa2ea236db51f24"
127
140
  Cache-Control:
128
141
  - max-age=0, private, must-revalidate
129
142
  Set-Cookie:
130
- - _exercises_session=LzR6d09ZRE1CUjZlR2Jac1FpMlkzeDl2VWFNYTJyQ1NGeGkxWjRxVHdVS095ckpwUFZMcytxUFByOXVJOHoxUFR1d3ozSzNycFBYYVUrOEY3TVU3eVE9PS0tb29QaldpV2lkaWZEZHlRblZjQVBjdz09--c93e2fa442d933cb679336585b1670ebf60fdb09;
131
- path=/; HttpOnly
132
143
  - request_method=POST; path=/
133
144
  X-Request-Id:
134
- - dca250e2-9c45-4f64-b584-a0f8f264a3f3
145
+ - 515dfba0-d765-4394-a479-644880f18d8b
135
146
  X-Runtime:
136
- - '0.040383'
147
+ - '0.055219'
137
148
  Connection:
138
149
  - close
139
150
  Server:
140
151
  - thin
141
152
  body:
142
- encoding: US-ASCII
143
- string: ! '{"identifier":"c2e144cf2fa6db7fe45015b20fe117293a75d8c778204507095e03e8fa60ebf9"}'
153
+ encoding: UTF-8
154
+ string: '{"read":"e6068fd59348d50507069636673b611a278ebf7b3372c4c693e2e2833ab19fa1","write":"a3beadfaaeff88078fd190adfc9ea0d774e94ffeb5e8fadf75c29b27fe6836d4"}'
144
155
  http_version:
145
- recorded_at: Mon, 12 Jan 2015 21:08:52 GMT
156
+ recorded_at: Tue, 28 Apr 2015 18:43:29 GMT
146
157
  recorded_with: VCR 2.9.3
@@ -8,7 +8,7 @@ http_interactions:
8
8
  string: grant_type=client_credentials
9
9
  headers:
10
10
  User-Agent:
11
- - Faraday v0.9.0
11
+ - Faraday v0.9.1
12
12
  Content-Type:
13
13
  - application/x-www-form-urlencoded
14
14
  Accept:
@@ -31,20 +31,21 @@ http_interactions:
31
31
  Content-Type:
32
32
  - application/json; charset=utf-8
33
33
  Etag:
34
- - W/"a9b0db9b60d09f7ce86486bddc6bd620"
34
+ - W/"e3d0e550ef1d47dc2d40b7d70e16eecf"
35
35
  X-Request-Id:
36
- - b62de81c-8bd7-4548-b970-555e429e996e
36
+ - fa9d9559-e16e-4318-b447-c24b8cc531b1
37
37
  X-Runtime:
38
- - '0.015645'
38
+ - '0.066830'
39
39
  Connection:
40
40
  - close
41
41
  Server:
42
42
  - thin
43
43
  body:
44
44
  encoding: US-ASCII
45
- string: ! '{"access_token":"c547f9ee886dcae47e755cead09009b4ff3d1bbd88db7a4fbe39207ab35c794d","token_type":"bearer"}'
45
+ string: ! '{"access_token":"177f3b0e42f693caee3761c653a0060104dea5afcc9cbad292e64b563c6e5296","token_type":"bearer","scope":"read
46
+ write","created_at":1430418522}'
46
47
  http_version:
47
- recorded_at: Mon, 12 Jan 2015 21:08:53 GMT
48
+ recorded_at: Thu, 30 Apr 2015 18:28:42 GMT
48
49
  - request:
49
50
  method: post
50
51
  uri: http://localhost:3003/api/identifiers
@@ -53,11 +54,13 @@ http_interactions:
53
54
  string: ''
54
55
  headers:
55
56
  User-Agent:
56
- - Faraday v0.9.0
57
+ - Faraday v0.9.1
57
58
  Accept:
58
59
  - application/vnd.exchange.openstax.v1
60
+ Content-Type:
61
+ - application/json
59
62
  Authorization:
60
- - Bearer c547f9ee886dcae47e755cead09009b4ff3d1bbd88db7a4fbe39207ab35c794d
63
+ - Bearer 177f3b0e42f693caee3761c653a0060104dea5afcc9cbad292e64b563c6e5296
61
64
  Content-Length:
62
65
  - '0'
63
66
  response:
@@ -71,44 +74,44 @@ http_interactions:
71
74
  - 1; mode=block
72
75
  X-Content-Type-Options:
73
76
  - nosniff
77
+ Date:
78
+ - Thu, 30 Apr 2015 18:28:42 GMT
74
79
  Content-Type:
75
80
  - application/json; charset=utf-8
76
81
  Etag:
77
- - W/"1e022fc97eee729685cc737484251224"
82
+ - W/"6d084a5cad37e1c244bdb5c111ab968a"
78
83
  Cache-Control:
79
84
  - max-age=0, private, must-revalidate
80
85
  Set-Cookie:
81
- - _exercises_session=WU1KU0h4VjlkaUMzdU01M1pwME5pLzVROG1QaHFGbnR0bzlKVXp4aE5HNm5wOG1oQW83QVdZZm1lUS9YT0JOUDVJbGFrMWxlakdTc243Tk4vdHBSL2c9PS0teW8xOVhVYTE0TTlETzdCcWhpek1RZz09--b92be7656418e43b4f27c7e83f4f5cac1b955a64;
82
- path=/; HttpOnly
83
86
  - request_method=POST; path=/
84
87
  X-Request-Id:
85
- - 28d45194-711a-413d-a47a-21bbc83aa72b
88
+ - 05ef7ac8-aa39-40f5-8a95-d769dfc28170
86
89
  X-Runtime:
87
- - '0.040288'
90
+ - '0.169319'
88
91
  Connection:
89
92
  - close
90
93
  Server:
91
94
  - thin
92
95
  body:
93
96
  encoding: US-ASCII
94
- string: ! '{"identifier":"34cdf6b6a4b45643b31b5cd63212e95cb55accb36080015048de5e7394f74841"}'
97
+ string: ! '{"read":"9dc1b20bb40a6e3f40a33405a0089ffb6fdd3b34f338eda3595da8a0df88d512","write":"2a3c4952254d5cd231df4971af97f71337c714085d30237020dba34b073fa1fa"}'
95
98
  http_version:
96
- recorded_at: Mon, 12 Jan 2015 21:08:53 GMT
99
+ recorded_at: Thu, 30 Apr 2015 18:28:42 GMT
97
100
  - request:
98
101
  method: post
99
102
  uri: http://localhost:3003/api/events/platforms/multiple_choices
100
103
  body:
101
104
  encoding: UTF-8
102
- string: ! '{"identifier":"34cdf6b6a4b45643b31b5cd63212e95cb55accb36080015048de5e7394f74841","resource":"http://exercises.openstax.org/exercises/1234","trial":"1","answer":"answer_string"}'
105
+ string: ! '{"identifier":"2a3c4952254d5cd231df4971af97f71337c714085d30237020dba34b073fa1fa","resource":"https://exercises-dev1.openstax.org/api/exercises/123@1","trial":"1","answer":"answer_string"}'
103
106
  headers:
104
107
  User-Agent:
105
- - Faraday v0.9.0
108
+ - Faraday v0.9.1
106
109
  Accept:
107
110
  - application/vnd.exchange.openstax.v1
108
111
  Authorization:
109
- - Bearer c547f9ee886dcae47e755cead09009b4ff3d1bbd88db7a4fbe39207ab35c794d
112
+ - Bearer 177f3b0e42f693caee3761c653a0060104dea5afcc9cbad292e64b563c6e5296
110
113
  Content-Type:
111
- - application/x-www-form-urlencoded
114
+ - application/json
112
115
  response:
113
116
  status:
114
117
  code: 201
@@ -120,48 +123,48 @@ http_interactions:
120
123
  - 1; mode=block
121
124
  X-Content-Type-Options:
122
125
  - nosniff
126
+ Date:
127
+ - Thu, 30 Apr 2015 18:28:43 GMT
123
128
  Content-Type:
124
129
  - application/json; charset=utf-8
125
130
  Etag:
126
- - W/"a8ac499a2a9e9dbf8c7c3083274494d7"
131
+ - W/"af86414af7354a54579425ee3702b3ef"
127
132
  Cache-Control:
128
133
  - max-age=0, private, must-revalidate
129
134
  Set-Cookie:
130
- - _exercises_session=YzVmZC9xY01WMnV5R0NTN2VyVXRJN1o3MkFibERUbkdGMitTK2VoNC9qeDVqSTJUY3JIdjRJUk9SM1gzdFZoalcyb3I0TTZVWWJ4SmhnUHBxWkxQS2c9PS0ta0NMM1ZpaDg4aWVTalpIMjRYcFdWUT09--fe66330b75140d7a608e3a93e92ed346ea94a214;
131
- path=/; HttpOnly
132
135
  - request_method=POST; path=/
133
136
  X-Request-Id:
134
- - 81931d67-6105-4d89-bdfe-73684beef41f
137
+ - 9cff5834-d1f1-4b2e-bf04-c8614e857f5f
135
138
  X-Runtime:
136
- - '0.080417'
139
+ - '0.274154'
137
140
  Connection:
138
141
  - close
139
142
  Server:
140
143
  - thin
141
144
  body:
142
145
  encoding: US-ASCII
143
- string: ! '{"identifier":"34cdf6b6a4b45643b31b5cd63212e95cb55accb36080015048de5e7394f74841","resource":"http://exercises.openstax.org/exercises/1234","trial":"1","created_at":"2015-01-12T21:08:53.550Z","answer_type":"multiple-choice","answer":"answer_string"}'
146
+ string: ! '{"identifier":"2a3c4952254d5cd231df4971af97f71337c714085d30237020dba34b073fa1fa","resource":"https://exercises-dev1.openstax.org/api/exercises/123@1","trial":"1","created_at":"2015-04-30T18:28:43.123Z","answer_type":"multiple-choice","answer":"answer_string"}'
144
147
  http_version:
145
- recorded_at: Mon, 12 Jan 2015 21:08:53 GMT
148
+ recorded_at: Thu, 30 Apr 2015 18:28:43 GMT
146
149
  - request:
147
150
  method: post
148
151
  uri: http://localhost:3003/api/events/platforms/multiple_choices
149
152
  body:
150
153
  encoding: UTF-8
151
- string: ! '{"identifier":"34cdf6b6a4b45643b31b5cd63212e95cb55accb36080015048de5e7394f74841","resource":"http://exercises.openstax.org/exercises/1234","trial":"1","answer":"answer_string"}'
154
+ string: ! '{"identifier":"2a3c4952254d5cd231df4971af97f71337c714085d30237020dba34b073fa1fa","resource":"https://exercises-dev1.openstax.org/api/exercises/123@1","trial":"1","answer":"another_string"}'
152
155
  headers:
153
156
  User-Agent:
154
- - Faraday v0.9.0
157
+ - Faraday v0.9.1
155
158
  Accept:
156
159
  - application/vnd.exchange.openstax.v1
157
160
  Authorization:
158
- - Bearer c547f9ee886dcae47e755cead09009b4ff3d1bbd88db7a4fbe39207ab35c794d
161
+ - Bearer 177f3b0e42f693caee3761c653a0060104dea5afcc9cbad292e64b563c6e5296
159
162
  Content-Type:
160
- - application/x-www-form-urlencoded
163
+ - application/json
161
164
  response:
162
165
  status:
163
- code: 422
164
- message: Unprocessable Entity
166
+ code: 201
167
+ message: Created
165
168
  headers:
166
169
  X-Frame-Options:
167
170
  - SAMEORIGIN
@@ -169,26 +172,27 @@ http_interactions:
169
172
  - 1; mode=block
170
173
  X-Content-Type-Options:
171
174
  - nosniff
175
+ Date:
176
+ - Thu, 30 Apr 2015 18:28:43 GMT
172
177
  Content-Type:
173
178
  - application/json; charset=utf-8
179
+ Etag:
180
+ - W/"7d5dc201a376c1a0764d6fa9252738af"
174
181
  Cache-Control:
175
- - no-cache
182
+ - max-age=0, private, must-revalidate
176
183
  Set-Cookie:
177
- - _exercises_session=MmlzQS9IZVEzNW1LN1pOTzNsSXFMVkIrVnRLaEJzaTRsNjl6MEI1ZmxWQXlkWnBBOWsvTUxGMjV6U2RLMFlPb2xlMnM2S3FKTjkyb0hJNEtaUTFUY3c9PS0tTFdFVEdRbUEweEluZWU1MjZEYkhqQT09--d606058ac3ab90d11d80a174fe0ff3700c986759;
178
- path=/; HttpOnly
179
184
  - request_method=POST; path=/
180
185
  X-Request-Id:
181
- - 91cad2b8-87ce-4063-8b1a-a62d3f28766e
186
+ - 42174994-50fc-46a3-a04b-302385f05e80
182
187
  X-Runtime:
183
- - '0.117100'
188
+ - '0.075426'
184
189
  Connection:
185
190
  - close
186
191
  Server:
187
192
  - thin
188
193
  body:
189
194
  encoding: US-ASCII
190
- string: ! '[{"code":"taken","data":{"model":{"id":null,"identifier_id":904,"resource_id":5,"trial":"1","due_at":null,"created_at":null,"updated_at":null},"attribute":"trial"},"kind":"activerecord","message":"has
191
- already been taken","offending_inputs":"trial"}]'
195
+ string: ! '{"identifier":"2a3c4952254d5cd231df4971af97f71337c714085d30237020dba34b073fa1fa","resource":"https://exercises-dev1.openstax.org/api/exercises/123@1","trial":"1","created_at":"2015-04-30T18:28:43.276Z","answer_type":"multiple-choice","answer":"another_string"}'
192
196
  http_version:
193
- recorded_at: Mon, 12 Jan 2015 21:08:53 GMT
197
+ recorded_at: Thu, 30 Apr 2015 18:28:43 GMT
194
198
  recorded_with: VCR 2.9.3