messagemedia_signingkeys_sdk 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e2e2b65cb2866ec5345a5827016239f9dc2b8c5f
4
- data.tar.gz: ac401ed597aa9a0fe11be1976916c25e2abfb82b
3
+ metadata.gz: dfc906c821d60856d2d5a3b326abc0832e8a7282
4
+ data.tar.gz: fe9bffe36d126e9e3bdf26c440be4c4cc830795a
5
5
  SHA512:
6
- metadata.gz: fd47694f3d6c43aebdd9890d6025e79ede2b2e401630b36fcf960b55dfaf6727d755ac7770b8dede6853683fac3f827455cdb0efcbf97ed9b9750c53267db961
7
- data.tar.gz: 90cc6efc17d9344874ca2821915de6f87707fea9278f3487bba6398ebfd5d7dabb0188154929c9b26ea6bb184fedc014fa0720aaa018fc02883e6dd0c275a48f
6
+ metadata.gz: 9f5f5513bbbf453bf100b3a18757c431abff54a3abdf1d1cf97a83a20943ead0c2a46c51324ab6722b65a2eed91b0f67320378b7201ab0e2d58cba5aa907fd8d
7
+ data.tar.gz: 15dd1b8494fefbf1c0464b97d5d40ca04275c9d8e1cecce65e432b62bd7dee4b81b3bddc52f46eccdc84cd9e822a59bf8b84921552144eaecf6d6e8409dd12f2
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # MessageMedia Signature Key Management Ruby SDK
2
- [![Build Status](https://travis-ci.org/messagemedia/signing-keys-nodejs-sdk.svg?branch=master)](https://travis-ci.org/messagemedia/signing-keys-nodejs-sdk)
3
- [![npm version](https://badge.fury.io/js/messagemedia-signingkeys-sdk.svg)](https://badge.fury.io/js/messagemedia-signingkeys-sdk)
2
+ [![Build Status](https://travis-ci.org/messagemedia/signing-keys-ruby-sdk.svg?branch=master)](https://travis-ci.org/messagemedia/signing-keys-ruby-sdk)
3
+ [![Gem Version](https://badge.fury.io/rb/messagemedia_signingkeys_sdk.svg)](https://badge.fury.io/rb/messagemedia_signingkeys_sdk)
4
4
 
5
5
  The MessageMedia Signature Key API provides a number of endpoints for managing key used to sign each unique request to ensure security and the requests can't (easily) be spoofed. This is similar to using HMAC in your outbound messaging (rather than HTTP Basic).
6
6
 
@@ -26,16 +26,13 @@ client = MessageMediaSigningKeys::MessageMediaSigningKeysClient.new(
26
26
 
27
27
  signatureKeyManagement_controller = client.signature_key_management
28
28
 
29
- content_type = 'Content-Type'
30
- accept = 'Accept'
31
- body_value = '{
32
- "digest": "SHA224",
33
- "cipher": "RSA"
34
- }';
35
-
29
+ body_value = "{
30
+ \"digest\": \"SHA224\",
31
+ \"cipher\": \"RSA\"
32
+ }";
36
33
  body = JSON.parse(body_value);
37
34
 
38
- result = signatureKeyManagement_controller.create_signature_key(content_type, accept, body)
35
+ result = signatureKeyManagement_controller.create_signature_key(body)
39
36
  pp result
40
37
 
41
38
  ```
@@ -58,10 +55,8 @@ client = MessageMediaSigningKeys::MessageMediaSigningKeysClient.new(
58
55
  signatureKeyManagement_controller = client.signature_key_management
59
56
 
60
57
  key_id = 'key_id'
61
- content_type = 'Content-Type'
62
- accept = 'Accept'
63
58
 
64
- result = signatureKeyManagement_controller.get_signature_key_detail(key_id, content_type, accept)
59
+ result = signatureKeyManagement_controller.get_signature_key_detail(key_id)
65
60
  pp result
66
61
 
67
62
  ```
@@ -82,12 +77,7 @@ client = MessageMediaSigningKeys::MessageMediaSigningKeysClient.new(
82
77
 
83
78
  signatureKeyManagement_controller = client.signature_key_management
84
79
 
85
- content_type = 'Content-Type'
86
- accept = 'Accept'
87
- page = 'page'
88
- page_size = 'page_size'
89
-
90
- result = signatureKeyManagement_controller.get_signature_key_list(content_type, accept, page, page_size)
80
+ result = signatureKeyManagement_controller.get_signature_key_list()
91
81
  pp result
92
82
 
93
83
  ```
@@ -109,10 +99,8 @@ client = MessageMediaSigningKeys::MessageMediaSigningKeysClient.new(
109
99
  signatureKeyManagement_controller = client.signature_key_management
110
100
 
111
101
  key_id = 'key_id'
112
- content_type = 'Content-Type'
113
- accept = 'Accept'
114
102
 
115
- signatureKeyManagement_controller.delete_signature_key(key_id, content_type, accept)
103
+ signatureKeyManagement_controller.delete_signature_key(key_id)
116
104
 
117
105
  ```
118
106
 
@@ -133,11 +121,11 @@ client = MessageMediaSigningKeys::MessageMediaSigningKeysClient.new(
133
121
 
134
122
  signatureKeyManagement_controller = client.signature_key_management
135
123
 
136
- content_type = 'Content-Type'
137
- accept = 'Accept'
138
- body = EnableSignatureKeyRequest.new
124
+ body = EnableSignatureKeyRequest.new({
125
+ "key_id": "7ca628a8-08b0-4e42-aeb8-960b37049c31"
126
+ })
139
127
 
140
- result = signatureKeyManagement_controller.update_enable_signature_key(content_type, accept, body)
128
+ result = signatureKeyManagement_controller.update_enable_signature_key(body)
141
129
  pp result
142
130
 
143
131
  ```
@@ -158,10 +146,7 @@ client = MessageMediaSigningKeys::MessageMediaSigningKeysClient.new(
158
146
 
159
147
  signatureKeyManagement_controller = client.signature_key_management
160
148
 
161
- content_type = 'Content-Type'
162
- accept = 'Accept'
163
-
164
- result = signatureKeyManagement_controller.get_enabled_signature_key(content_type, accept)
149
+ result = signatureKeyManagement_controller.get_enabled_signature_key()
165
150
  pp result
166
151
 
167
152
  ```
@@ -181,10 +166,7 @@ client = MessageMediaSigningKeys::MessageMediaSigningKeysClient.new(
181
166
 
182
167
  signatureKeyManagement_controller = client.signature_key_management
183
168
 
184
- content_type = 'Content-Type'
185
- accept = 'Accept'
186
-
187
- signatureKeyManagement_controller.delete_disable_the_current_enabled_signature_key(content_type, accept)
169
+ signatureKeyManagement_controller.delete_disable_the_current_enabled_signature_key()
188
170
 
189
171
  ```
190
172
 
@@ -30,15 +30,25 @@ require_relative 'message_media_signing_keys/models/get_signature_key_list' \
30
30
  '_response.rb'
31
31
  require_relative 'message_media_signing_keys/models/get_signature_key_detail' \
32
32
  '_response.rb'
33
- require_relative 'message_media_signing_keys/models/create_signature_key' \
33
+ require_relative 'message_media_signing_keys/models/enable_signature_key' \
34
34
  '_request.rb'
35
35
  require_relative 'message_media_signing_keys/models/create_signature_key' \
36
36
  '_response.rb'
37
- require_relative 'message_media_signing_keys/models/enable_signature_key' \
37
+ require_relative 'message_media_signing_keys/models/create_signature_key' \
38
38
  '_request.rb'
39
39
 
40
40
  # Exceptions
41
41
  require_relative 'message_media_signing_keys/exceptions/api_exception.rb'
42
+ require_relative 'message_media_signing_keys/exceptions/disable_the_current' \
43
+ '_enabled_signature_key403_response_exception.rb'
44
+ require_relative 'message_media_signing_keys/exceptions/get_enabled_signature' \
45
+ '_key403_response_exception.rb'
46
+ require_relative 'message_media_signing_keys/exceptions/enable_signature' \
47
+ '_key403_response_exception.rb'
48
+ require_relative 'message_media_signing_keys/exceptions/enable_signature' \
49
+ '_key400_response_exception.rb'
50
+ require_relative 'message_media_signing_keys/exceptions/get_signature_key' \
51
+ '_list403_response_exception.rb'
42
52
  require_relative 'message_media_signing_keys/exceptions/get_signature_key' \
43
53
  '_list400_response_exception.rb'
44
54
  require_relative 'message_media_signing_keys/exceptions/delete_signature' \
@@ -51,16 +61,6 @@ require_relative 'message_media_signing_keys/exceptions/create_signature' \
51
61
  '_key403_response_exception.rb'
52
62
  require_relative 'message_media_signing_keys/exceptions/create_signature' \
53
63
  '_key400_response_exception.rb'
54
- require_relative 'message_media_signing_keys/exceptions/disable_the_current' \
55
- '_enabled_signature_key403_response_exception.rb'
56
- require_relative 'message_media_signing_keys/exceptions/get_enabled_signature' \
57
- '_key403_response_exception.rb'
58
- require_relative 'message_media_signing_keys/exceptions/enable_signature' \
59
- '_key403_response_exception.rb'
60
- require_relative 'message_media_signing_keys/exceptions/enable_signature' \
61
- '_key400_response_exception.rb'
62
- require_relative 'message_media_signing_keys/exceptions/get_signature_key' \
63
- '_list403_response_exception.rb'
64
64
 
65
65
  require_relative 'message_media_signing_keys/configuration.rb'
66
66
 
@@ -11,7 +11,7 @@ module MessageMediaSigningKeys
11
11
  @http_call_back = http_call_back
12
12
 
13
13
  @global_headers = {
14
- 'user-agent' => 'messagemedia-signingkeys-sdk-1.0.0'
14
+ 'user-agent' => 'messagemedia-signingkeys-sdk-1.1.0'
15
15
  }
16
16
  @logger = Logging.logger[self]
17
17
  @logger.info("Instantiated controller class.")
@@ -21,11 +21,8 @@ module MessageMediaSigningKeys
21
21
  # is returned.
22
22
  # If there is no key or no enabled key, the 204 status code is also
23
23
  # returned.
24
- # @param [String] content_type Required parameter: Example:
25
- # @param [String] accept Required parameter: Example:
26
24
  # @return void response from the API call
27
- def delete_disable_the_current_enabled_signature_key(content_type,
28
- accept)
25
+ def delete_disable_the_current_enabled_signature_key
29
26
  begin
30
27
  @logger.info("delete_disable_the_current_enabled_signature_key called.")
31
28
  # Prepare query url.
@@ -34,18 +31,10 @@ module MessageMediaSigningKeys
34
31
  _query_builder << '/v1/iam/signature_keys/enabled'
35
32
  _query_url = APIHelper.clean_url _query_builder
36
33
 
37
- # Prepare headers.
38
- @logger.info("Preparing headers for delete_disable_the_current_enabled_signature_key.")
39
- _headers = {
40
- 'Content-Type' => content_type,
41
- 'Accept' => accept
42
- }
43
-
44
34
  # Prepare and execute HttpRequest.
45
35
  @logger.info('Preparing and executing HttpRequest for delete_disable_the_current_enabled_signature_key.')
46
36
  _request = @http_client.delete(
47
- _query_url,
48
- headers: _headers
37
+ _query_url
49
38
  )
50
39
  BasicAuth.apply(_request)
51
40
  _context = execute_request(_request, name: 'delete_disable_the_current_enabled_signature_key')
@@ -57,56 +46,59 @@ module MessageMediaSigningKeys
57
46
  end
58
47
  end
59
48
 
60
- # Delete a signature key using the key_id returned in the ```create
61
- # signature key``` endpoint.
62
- # A successful request for the ```delete signature key``` endpoint will
63
- # return an empty response body.
64
- # *Note: If an invalid or non-existent key_id parameter is specified in the
65
- # request, then an HTTP 404 Not Found response will be returned*
66
- # @param [String] key_id Required parameter: Example:
67
- # @param [String] content_type Required parameter: Example:
68
- # @param [String] accept Required parameter: Example:
69
- # @return void response from the API call
70
- def delete_signature_key(key_id,
71
- content_type,
72
- accept)
49
+ # Retrieve the currently enabled signature key.
50
+ # A successful request for the ```get enabled signature key``` endpoint will
51
+ # return a response body as follows:
52
+ # ```json
53
+ # {
54
+ # "key_id": "7ca628a8-08b0-4e42-aeb8-960b37049c31",
55
+ # "cipher": "RSA",
56
+ # "digest": "SHA224",
57
+ # "created": "2018-01-18T10:16:12.364Z",
58
+ # "enabled": true
59
+ # }
60
+ # ```
61
+ # *Note: If there is no enabled signature key, then an HTTP 404 Not Found
62
+ # response will be returned*
63
+ # @return GetEnabledSignatureKeyResponse response from the API call
64
+ def get_enabled_signature_key
73
65
  begin
74
- @logger.info("delete_signature_key called.")
66
+ @logger.info("get_enabled_signature_key called.")
75
67
  # Prepare query url.
76
- @logger.info("Preparing query URL for delete_signature_key.")
68
+ @logger.info("Preparing query URL for get_enabled_signature_key.")
77
69
  _query_builder = Configuration.base_uri.dup
78
- _query_builder << '/v1/iam/signature_keys/{key_id}'
79
- _query_builder = APIHelper.append_url_with_template_parameters(
80
- _query_builder,
81
- 'key_id' => key_id
82
- )
70
+ _query_builder << '/v1/iam/signature_keys/enabled'
83
71
  _query_url = APIHelper.clean_url _query_builder
84
72
 
85
73
  # Prepare headers.
86
- @logger.info("Preparing headers for delete_signature_key.")
74
+ @logger.info("Preparing headers for get_enabled_signature_key.")
87
75
  _headers = {
88
- 'Content-Type' => content_type,
89
- 'Accept' => accept
76
+ 'accept' => 'application/json'
90
77
  }
91
78
 
92
79
  # Prepare and execute HttpRequest.
93
- @logger.info('Preparing and executing HttpRequest for delete_signature_key.')
94
- _request = @http_client.delete(
80
+ @logger.info('Preparing and executing HttpRequest for get_enabled_signature_key.')
81
+ _request = @http_client.get(
95
82
  _query_url,
96
83
  headers: _headers
97
84
  )
98
85
  BasicAuth.apply(_request)
99
- _context = execute_request(_request, name: 'delete_signature_key')
86
+ _context = execute_request(_request, name: 'get_enabled_signature_key')
100
87
 
101
88
  # Validate response against endpoint and global error codes.
102
- @logger.info("Validating response for delete_signature_key.")
89
+ @logger.info("Validating response for get_enabled_signature_key.")
103
90
  if _context.response.status_code == 404
104
- raise DeleteSignatureKey403ResponseException.new(
91
+ raise GetEnabledSignatureKey403ResponseException.new(
105
92
  'Unexpected error in API call. See HTTP response body for details.',
106
93
  _context
107
94
  )
108
95
  end
109
96
  validate_response(_context)
97
+
98
+ # Return appropriate response type.
99
+ @logger.info("Returning response for get_enabled_signature_key.")
100
+ decoded = APIHelper.json_deserialize(_context.response.raw_body)
101
+ GetEnabledSignatureKeyResponse.from_hash(decoded)
110
102
 
111
103
  rescue Exception => e
112
104
  @logger.error(e)
@@ -114,65 +106,67 @@ module MessageMediaSigningKeys
114
106
  end
115
107
  end
116
108
 
117
- # Retrieve the current detail of a signature key using the key_id returned
118
- # in the ```create signature key``` endpoint.
119
- # A successful request for the ```get signature key detail``` endpoint will
120
- # return a response body as follows:
109
+ # Enable a signature key using the key_id returned in the ```create
110
+ # signature key``` endpoint.
111
+ # There is only one signature key is enabled at the one moment in time. So
112
+ # if you enable the new signature key, the old one will be disabled.
113
+ # The most basic body has the following structure:
114
+ # ```json
115
+ # {
116
+ # "key_id": "7ca628a8-08b0-4e42-aeb8-960b37049c31"
117
+ # }
118
+ # ```
119
+ # The response body of a successful PATCH request to ```enable signature
120
+ # key``` endpoint will contain the ```enabled``` properties with the value
121
+ # is true as follows:
121
122
  # ```json
122
123
  # {
123
124
  # "key_id": "7ca628a8-08b0-4e42-aeb8-960b37049c31",
124
125
  # "cipher": "RSA",
125
126
  # "digest": "SHA224",
126
127
  # "created": "2018-01-18T10:16:12.364Z",
127
- # "enabled": false
128
+ # "enabled": true
128
129
  # }
129
130
  # ```
130
131
  # *Note: If an invalid or non-existent key_id parameter is specified in the
131
132
  # request, then an HTTP 404 Not Found response will be returned*
132
- # @param [String] key_id Required parameter: Example:
133
- # @param [String] content_type Required parameter: Example:
134
- # @param [String] accept Required parameter: Example:
135
- # @return GETSignatureKeyDetailResponse response from the API call
136
- def get_signature_key_detail(key_id,
137
- content_type,
138
- accept)
133
+ # @param [EnableSignatureKeyRequest] body Required parameter: Example:
134
+ # @return EnableSignatureKeyResponse response from the API call
135
+ def update_enable_signature_key(body)
139
136
  begin
140
- @logger.info("get_signature_key_detail called.")
137
+ @logger.info("update_enable_signature_key called.")
141
138
  # Prepare query url.
142
- @logger.info("Preparing query URL for get_signature_key_detail.")
139
+ @logger.info("Preparing query URL for update_enable_signature_key.")
143
140
  _query_builder = Configuration.base_uri.dup
144
- _query_builder << '/v1/iam/signature_keys/{key_id}'
145
- _query_builder = APIHelper.append_url_with_template_parameters(
146
- _query_builder,
147
- 'key_id' => key_id
148
- )
141
+ _query_builder << '/v1/iam/signature_keys/enabled'
149
142
  _query_url = APIHelper.clean_url _query_builder
150
143
 
151
144
  # Prepare headers.
152
- @logger.info("Preparing headers for get_signature_key_detail.")
145
+ @logger.info("Preparing headers for update_enable_signature_key.")
153
146
  _headers = {
154
- 'Content-Type' => content_type,
155
- 'Accept' => accept
147
+ 'accept' => 'application/json',
148
+ 'content-type' => 'application/json; charset=utf-8'
156
149
  }
157
150
 
158
151
  # Prepare and execute HttpRequest.
159
- @logger.info('Preparing and executing HttpRequest for get_signature_key_detail.')
160
- _request = @http_client.get(
152
+ @logger.info('Preparing and executing HttpRequest for update_enable_signature_key.')
153
+ _request = @http_client.patch(
161
154
  _query_url,
162
- headers: _headers
155
+ headers: _headers,
156
+ parameters: body.to_json
163
157
  )
164
158
  BasicAuth.apply(_request)
165
- _context = execute_request(_request, name: 'get_signature_key_detail')
159
+ _context = execute_request(_request, name: 'update_enable_signature_key')
166
160
 
167
161
  # Validate response against endpoint and global error codes.
168
- @logger.info("Validating response for get_signature_key_detail.")
162
+ @logger.info("Validating response for update_enable_signature_key.")
169
163
  if _context.response.status_code == 400
170
- raise GETSignatureKeyDetail400ResponseException.new(
164
+ raise EnableSignatureKey400ResponseException.new(
171
165
  'Unexpected error in API call. See HTTP response body for details.',
172
166
  _context
173
167
  )
174
168
  elsif _context.response.status_code == 404
175
- raise GETSignatureKeyDetail403ResponseException.new(
169
+ raise EnableSignatureKey403ResponseException.new(
176
170
  'Unexpected error in API call. See HTTP response body for details.',
177
171
  _context
178
172
  )
@@ -180,9 +174,9 @@ module MessageMediaSigningKeys
180
174
  validate_response(_context)
181
175
 
182
176
  # Return appropriate response type.
183
- @logger.info("Returning response for get_signature_key_detail.")
177
+ @logger.info("Returning response for update_enable_signature_key.")
184
178
  decoded = APIHelper.json_deserialize(_context.response.raw_body)
185
- GETSignatureKeyDetailResponse.from_hash(decoded)
179
+ EnableSignatureKeyResponse.from_hash(decoded)
186
180
 
187
181
  rescue Exception => e
188
182
  @logger.error(e)
@@ -190,84 +184,49 @@ module MessageMediaSigningKeys
190
184
  end
191
185
  end
192
186
 
193
- # This will create a key pair:
194
- # - The ```private key``` stored in MessageMedia is used to create the
195
- # signature.
196
- # - The ```public key``` is returned and stored at your side to verify the
197
- # signature in callbacks.
198
- # You need to enable your signature key after creating.
199
- # The most basic body has the following structure:
200
- # ```json
201
- # {
202
- # "digest": "SHA224",
203
- # "cipher": "RSA"
204
- # }
205
- # ```
206
- # - ```digest``` is used to hash the message. The valid values for digest
207
- # type are: SHA224, SHA256, SHA512
208
- # - ```cipher``` is used to encrypt the hashed message. The valid value for
209
- # cipher type is: RSA
210
- # A successful request for the ```create signature key``` endpoint will
187
+ # Retrieve the paginated list of signature keys.
188
+ # A successful request for the ```get signature key list``` endpoint will
211
189
  # return a response body as follows:
212
190
  # ```json
213
- # {
191
+ # [
192
+ # {
214
193
  # "key_id": "7ca628a8-08b0-4e42-aeb8-960b37049c31",
215
- # "public_key":
216
- # "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCTIxtRyT5CuOD74r7UCT+AKzWNxvaAP9myj
217
- # AqR7+vBnJKEvoPnmbKTnm6uLlxutnMbjKrnCCWnQ9vtBVnnd+ElhwLDPADfMcJoOqwi7mTcxuc
218
- # ckeEbBsfsgYRfdacxgSZL8hVD1hLViQr3xwjEIkJcx1w3x8npvwMuTY0uW8+PjwIDAQAB",
219
194
  # "cipher": "RSA",
220
195
  # "digest": "SHA224",
221
196
  # "created": "2018-01-18T10:16:12.364Z",
222
197
  # "enabled": false
223
- # }
198
+ # }
199
+ # ]
224
200
  # ```
225
- # The response body of a successful POST request to the ```create signature
226
- # key``` endpoint will contain six properties:
227
- # - ```key_id``` will be a 36 character UUID which can be used to enable,
228
- # delete or get the details.
229
- # - ```public_key``` is used to decrypt the signature.
230
- # - ```cipher``` same as cipher in request body.
231
- # - ```digest``` same as digest in request body.
232
- # - ```created``` is the created date.
233
- # - ```enabled``` is false for the new signature key. You can use the
234
- # ```enable signature key``` endpoint to set this field to true.
235
- # @param [String] content_type Required parameter: Example:
236
- # @param [String] accept Required parameter: Example:
237
- # @param [CreateSignatureKeyRequest] body Required parameter: Example:
238
- # @return CreateSignatureKeyResponse response from the API call
239
- def create_signature_key(content_type,
240
- accept,
241
- body)
201
+ # @return List of GetSignatureKeyListResponse response from the API call
202
+ def get_signature_key_list
242
203
  begin
243
- @logger.info("create_signature_key called.")
204
+ @logger.info("get_signature_key_list called.")
244
205
  # Prepare query url.
245
- @logger.info("Preparing query URL for create_signature_key.")
206
+ @logger.info("Preparing query URL for get_signature_key_list.")
246
207
  _query_builder = Configuration.base_uri.dup
247
208
  _query_builder << '/v1/iam/signature_keys'
248
209
  _query_url = APIHelper.clean_url _query_builder
249
210
 
250
211
  # Prepare headers.
251
- @logger.info("Preparing headers for create_signature_key.")
212
+ @logger.info("Preparing headers for get_signature_key_list.")
252
213
  _headers = {
253
- 'Content-Type' => content_type,
254
- 'Accept' => accept
214
+ 'accept' => 'application/json'
255
215
  }
256
216
 
257
217
  # Prepare and execute HttpRequest.
258
- @logger.info('Preparing and executing HttpRequest for create_signature_key.')
259
- _request = @http_client.post(
218
+ @logger.info('Preparing and executing HttpRequest for get_signature_key_list.')
219
+ _request = @http_client.get(
260
220
  _query_url,
261
- headers: _headers,
262
- parameters: body.to_json
221
+ headers: _headers
263
222
  )
264
223
  BasicAuth.apply(_request)
265
- _context = execute_request(_request, name: 'create_signature_key')
224
+ _context = execute_request(_request, name: 'get_signature_key_list')
266
225
 
267
226
  # Validate response against endpoint and global error codes.
268
- @logger.info("Validating response for create_signature_key.")
227
+ @logger.info("Validating response for get_signature_key_list.")
269
228
  if _context.response.status_code == 400
270
- raise CreateSignatureKey400ResponseException.new(
229
+ raise GetSignatureKeyList400ResponseException.new(
271
230
  'Unexpected error in API call. See HTTP response body for details.',
272
231
  _context
273
232
  )
@@ -275,9 +234,9 @@ module MessageMediaSigningKeys
275
234
  validate_response(_context)
276
235
 
277
236
  # Return appropriate response type.
278
- @logger.info("Returning response for create_signature_key.")
237
+ @logger.info("Returning response for get_signature_key_list.")
279
238
  decoded = APIHelper.json_deserialize(_context.response.raw_body)
280
- CreateSignatureKeyResponse.from_hash(decoded)
239
+ decoded.map { |element| GetSignatureKeyListResponse.from_hash(element) }
281
240
 
282
241
  rescue Exception => e
283
242
  @logger.error(e)
@@ -285,63 +244,44 @@ module MessageMediaSigningKeys
285
244
  end
286
245
  end
287
246
 
288
- # Retrieve the currently enabled signature key.
289
- # A successful request for the ```get enabled signature key``` endpoint will
290
- # return a response body as follows:
291
- # ```json
292
- # {
293
- # "key_id": "7ca628a8-08b0-4e42-aeb8-960b37049c31",
294
- # "cipher": "RSA",
295
- # "digest": "SHA224",
296
- # "created": "2018-01-18T10:16:12.364Z",
297
- # "enabled": true
298
- # }
299
- # ```
300
- # *Note: If there is no enabled signature key, then an HTTP 404 Not Found
301
- # response will be returned*
302
- # @param [String] content_type Required parameter: Example:
303
- # @param [String] accept Required parameter: Example:
304
- # @return GetEnabledSignatureKeyResponse response from the API call
305
- def get_enabled_signature_key(content_type,
306
- accept)
247
+ # Delete a signature key using the key_id returned in the ```create
248
+ # signature key``` endpoint.
249
+ # A successful request for the ```delete signature key``` endpoint will
250
+ # return an empty response body.
251
+ # *Note: If an invalid or non-existent key_id parameter is specified in the
252
+ # request, then an HTTP 404 Not Found response will be returned*
253
+ # @param [String] key_id Required parameter: Example:
254
+ # @return void response from the API call
255
+ def delete_signature_key(key_id)
307
256
  begin
308
- @logger.info("get_enabled_signature_key called.")
257
+ @logger.info("delete_signature_key called.")
309
258
  # Prepare query url.
310
- @logger.info("Preparing query URL for get_enabled_signature_key.")
259
+ @logger.info("Preparing query URL for delete_signature_key.")
311
260
  _query_builder = Configuration.base_uri.dup
312
- _query_builder << '/v1/iam/signature_keys/enabled'
261
+ _query_builder << '/v1/iam/signature_keys/{key_id}'
262
+ _query_builder = APIHelper.append_url_with_template_parameters(
263
+ _query_builder,
264
+ 'key_id' => key_id
265
+ )
313
266
  _query_url = APIHelper.clean_url _query_builder
314
267
 
315
- # Prepare headers.
316
- @logger.info("Preparing headers for get_enabled_signature_key.")
317
- _headers = {
318
- 'Content-Type' => content_type,
319
- 'Accept' => accept
320
- }
321
-
322
268
  # Prepare and execute HttpRequest.
323
- @logger.info('Preparing and executing HttpRequest for get_enabled_signature_key.')
324
- _request = @http_client.get(
325
- _query_url,
326
- headers: _headers
269
+ @logger.info('Preparing and executing HttpRequest for delete_signature_key.')
270
+ _request = @http_client.delete(
271
+ _query_url
327
272
  )
328
273
  BasicAuth.apply(_request)
329
- _context = execute_request(_request, name: 'get_enabled_signature_key')
274
+ _context = execute_request(_request, name: 'delete_signature_key')
330
275
 
331
276
  # Validate response against endpoint and global error codes.
332
- @logger.info("Validating response for get_enabled_signature_key.")
277
+ @logger.info("Validating response for delete_signature_key.")
333
278
  if _context.response.status_code == 404
334
- raise GetEnabledSignatureKey403ResponseException.new(
279
+ raise DeleteSignatureKey403ResponseException.new(
335
280
  'Unexpected error in API call. See HTTP response body for details.',
336
281
  _context
337
282
  )
338
283
  end
339
284
  validate_response(_context)
340
-
341
- # Return appropriate response type.
342
- @logger.info("Returning response for get_enabled_signature_key.")
343
- decoded = APIHelper.json_deserialize(_context.response.raw_body)
344
- GetEnabledSignatureKeyResponse.from_hash(decoded)
345
285
 
346
286
  rescue Exception => e
347
287
  @logger.error(e)
@@ -349,71 +289,60 @@ module MessageMediaSigningKeys
349
289
  end
350
290
  end
351
291
 
352
- # Enable a signature key using the key_id returned in the ```create
353
- # signature key``` endpoint.
354
- # There is only one signature key is enabled at the one moment in time. So
355
- # if you enable the new signature key, the old one will be disabled.
356
- # The most basic body has the following structure:
357
- # ```json
358
- # {
359
- # "key_id": "7ca628a8-08b0-4e42-aeb8-960b37049c31"
360
- # }
361
- # ```
362
- # The response body of a successful PATCH request to ```enable signature
363
- # key``` endpoint will contain the ```enabled``` properties with the value
364
- # is true as follows:
292
+ # Retrieve the current detail of a signature key using the key_id returned
293
+ # in the ```create signature key``` endpoint.
294
+ # A successful request for the ```get signature key detail``` endpoint will
295
+ # return a response body as follows:
365
296
  # ```json
366
297
  # {
367
298
  # "key_id": "7ca628a8-08b0-4e42-aeb8-960b37049c31",
368
299
  # "cipher": "RSA",
369
300
  # "digest": "SHA224",
370
301
  # "created": "2018-01-18T10:16:12.364Z",
371
- # "enabled": true
302
+ # "enabled": false
372
303
  # }
373
304
  # ```
374
305
  # *Note: If an invalid or non-existent key_id parameter is specified in the
375
306
  # request, then an HTTP 404 Not Found response will be returned*
376
- # @param [String] content_type Required parameter: Example:
377
- # @param [String] accept Required parameter: Example:
378
- # @param [EnableSignatureKeyRequest] body Required parameter: Example:
379
- # @return EnableSignatureKeyResponse response from the API call
380
- def update_enable_signature_key(content_type,
381
- accept,
382
- body)
307
+ # @param [String] key_id Required parameter: Example:
308
+ # @return GetSignatureKeyDetailResponse response from the API call
309
+ def get_signature_key_detail(key_id)
383
310
  begin
384
- @logger.info("update_enable_signature_key called.")
311
+ @logger.info("get_signature_key_detail called.")
385
312
  # Prepare query url.
386
- @logger.info("Preparing query URL for update_enable_signature_key.")
313
+ @logger.info("Preparing query URL for get_signature_key_detail.")
387
314
  _query_builder = Configuration.base_uri.dup
388
- _query_builder << '/v1/iam/signature_keys/enabled'
315
+ _query_builder << '/v1/iam/signature_keys/{key_id}'
316
+ _query_builder = APIHelper.append_url_with_template_parameters(
317
+ _query_builder,
318
+ 'key_id' => key_id
319
+ )
389
320
  _query_url = APIHelper.clean_url _query_builder
390
321
 
391
322
  # Prepare headers.
392
- @logger.info("Preparing headers for update_enable_signature_key.")
323
+ @logger.info("Preparing headers for get_signature_key_detail.")
393
324
  _headers = {
394
- 'Content-Type' => content_type,
395
- 'Accept' => accept
325
+ 'accept' => 'application/json'
396
326
  }
397
327
 
398
328
  # Prepare and execute HttpRequest.
399
- @logger.info('Preparing and executing HttpRequest for update_enable_signature_key.')
400
- _request = @http_client.patch(
329
+ @logger.info('Preparing and executing HttpRequest for get_signature_key_detail.')
330
+ _request = @http_client.get(
401
331
  _query_url,
402
- headers: _headers,
403
- parameters: body.to_json
332
+ headers: _headers
404
333
  )
405
334
  BasicAuth.apply(_request)
406
- _context = execute_request(_request, name: 'update_enable_signature_key')
335
+ _context = execute_request(_request, name: 'get_signature_key_detail')
407
336
 
408
337
  # Validate response against endpoint and global error codes.
409
- @logger.info("Validating response for update_enable_signature_key.")
338
+ @logger.info("Validating response for get_signature_key_detail.")
410
339
  if _context.response.status_code == 400
411
- raise EnableSignatureKey400ResponseException.new(
340
+ raise GetSignatureKeyDetail400ResponseException.new(
412
341
  'Unexpected error in API call. See HTTP response body for details.',
413
342
  _context
414
343
  )
415
344
  elsif _context.response.status_code == 404
416
- raise EnableSignatureKey403ResponseException.new(
345
+ raise GetSignatureKeyDetail403ResponseException.new(
417
346
  'Unexpected error in API call. See HTTP response body for details.',
418
347
  _context
419
348
  )
@@ -421,9 +350,9 @@ module MessageMediaSigningKeys
421
350
  validate_response(_context)
422
351
 
423
352
  # Return appropriate response type.
424
- @logger.info("Returning response for update_enable_signature_key.")
353
+ @logger.info("Returning response for get_signature_key_detail.")
425
354
  decoded = APIHelper.json_deserialize(_context.response.raw_body)
426
- EnableSignatureKeyResponse.from_hash(decoded)
355
+ GetSignatureKeyDetailResponse.from_hash(decoded)
427
356
 
428
357
  rescue Exception => e
429
358
  @logger.error(e)
@@ -431,62 +360,80 @@ module MessageMediaSigningKeys
431
360
  end
432
361
  end
433
362
 
434
- # Retrieve the paginated list of signature keys.
435
- # A successful request for the ```get signature key list``` endpoint will
363
+ # This will create a key pair:
364
+ # - The ```private key``` stored in MessageMedia is used to create the
365
+ # signature.
366
+ # - The ```public key``` is returned and stored at your side to verify the
367
+ # signature in callbacks.
368
+ # You need to enable your signature key after creating.
369
+ # The most basic body has the following structure:
370
+ # ```json
371
+ # {
372
+ # "digest": "SHA224",
373
+ # "cipher": "RSA"
374
+ # }
375
+ # ```
376
+ # - ```digest``` is used to hash the message. The valid values for digest
377
+ # type are: SHA224, SHA256, SHA512
378
+ # - ```cipher``` is used to encrypt the hashed message. The valid value for
379
+ # cipher type is: RSA
380
+ # A successful request for the ```create signature key``` endpoint will
436
381
  # return a response body as follows:
437
382
  # ```json
438
- # [
439
- # {
383
+ # {
440
384
  # "key_id": "7ca628a8-08b0-4e42-aeb8-960b37049c31",
385
+ # "public_key":
386
+ # "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCTIxtRyT5CuOD74r7UCT+AKzWNxvaAP9myj
387
+ # AqR7+vBnJKEvoPnmbKTnm6uLlxutnMbjKrnCCWnQ9vtBVnnd+ElhwLDPADfMcJoOqwi7mTcxuc
388
+ # ckeEbBsfsgYRfdacxgSZL8hVD1hLViQr3xwjEIkJcx1w3x8npvwMuTY0uW8+PjwIDAQAB",
441
389
  # "cipher": "RSA",
442
390
  # "digest": "SHA224",
443
391
  # "created": "2018-01-18T10:16:12.364Z",
444
392
  # "enabled": false
445
- # }
446
- # ]
393
+ # }
447
394
  # ```
448
- # @param [String] content_type Required parameter: Example:
449
- # @param [String] accept Required parameter: Example:
450
- # @param [String] page Optional parameter: Example:
451
- # @param [String] page_size Optional parameter: Example:
452
- # @return List of GETSignatureKeyListResponse response from the API call
453
- def get_signature_key_list(content_type,
454
- accept,
455
- page = nil,
456
- page_size = nil)
395
+ # The response body of a successful POST request to the ```create signature
396
+ # key``` endpoint will contain six properties:
397
+ # - ```key_id``` will be a 36 character UUID which can be used to enable,
398
+ # delete or get the details.
399
+ # - ```public_key``` is used to decrypt the signature.
400
+ # - ```cipher``` same as cipher in request body.
401
+ # - ```digest``` same as digest in request body.
402
+ # - ```created``` is the created date.
403
+ # - ```enabled``` is false for the new signature key. You can use the
404
+ # ```enable signature key``` endpoint to set this field to true.
405
+ # @param [CreateSignatureKeyRequest] body Required parameter: Example:
406
+ # @return CreateSignatureKeyResponse response from the API call
407
+ def create_signature_key(body)
457
408
  begin
458
- @logger.info("get_signature_key_list called.")
409
+ @logger.info("create_signature_key called.")
459
410
  # Prepare query url.
460
- @logger.info("Preparing query URL for get_signature_key_list.")
411
+ @logger.info("Preparing query URL for create_signature_key.")
461
412
  _query_builder = Configuration.base_uri.dup
462
- _query_builder << '/v1/iam/signature_keys?page={page}&page_size={page_size}'
463
- _query_builder = APIHelper.append_url_with_template_parameters(
464
- _query_builder,
465
- 'page' => page,
466
- 'page_size' => page_size
467
- )
413
+ _query_builder << '/v1/iam/signature_keys'
468
414
  _query_url = APIHelper.clean_url _query_builder
469
415
 
470
416
  # Prepare headers.
471
- @logger.info("Preparing headers for get_signature_key_list.")
417
+ @logger.info("Preparing headers for create_signature_key.")
472
418
  _headers = {
473
- 'Content-Type' => content_type,
474
- 'Accept' => accept
419
+ 'accept' => 'application/json',
420
+ 'content-type' => 'application/json; charset=utf-8'
475
421
  }
476
422
 
477
423
  # Prepare and execute HttpRequest.
478
- @logger.info('Preparing and executing HttpRequest for get_signature_key_list.')
479
- _request = @http_client.get(
424
+ @logger.info('Preparing and executing HttpRequest for create_signature_key.')
425
+ _request = @http_client.post(
480
426
  _query_url,
481
- headers: _headers
427
+ headers: _headers,
428
+ parameters: body.to_json
482
429
  )
483
430
  BasicAuth.apply(_request)
484
- _context = execute_request(_request, name: 'get_signature_key_list')
431
+ _context = execute_request(_request, name: 'create_signature_key')
485
432
 
486
433
  # Validate response against endpoint and global error codes.
487
- @logger.info("Validating response for get_signature_key_list.")
434
+ @logger.info("Validating response for create_signature_key.")
488
435
  if _context.response.status_code == 400
489
- raise GETSignatureKeyList400ResponseException.new(
436
+ raise CreateSignatureKey400ResponseException.new(
490
437
  'Unexpected error in API call. See HTTP response body for details.',
491
438
  _context
492
439
  )
@@ -494,9 +441,9 @@ module MessageMediaSigningKeys
494
441
  validate_response(_context)
495
442
 
496
443
  # Return appropriate response type.
497
- @logger.info("Returning response for get_signature_key_list.")
444
+ @logger.info("Returning response for create_signature_key.")
498
445
  decoded = APIHelper.json_deserialize(_context.response.raw_body)
499
- decoded.map { |element| GETSignatureKeyListResponse.from_hash(element) }
446
+ CreateSignatureKeyResponse.from_hash(decoded)
500
447
 
501
448
  rescue Exception => e
502
449
  @logger.error(e)
@@ -2,8 +2,8 @@
2
2
  # ( https://apimatic.io ).
3
3
 
4
4
  module MessageMediaSigningKeys
5
- # GET signature key detail 400 response class.
6
- class GETSignatureKeyDetail400ResponseException < APIException
5
+ # Get signature key detail 400 response class.
6
+ class GetSignatureKeyDetail400ResponseException < APIException
7
7
  # TODO: Write general description for this method
8
8
  # @return [String]
9
9
  attr_accessor :message
@@ -2,8 +2,8 @@
2
2
  # ( https://apimatic.io ).
3
3
 
4
4
  module MessageMediaSigningKeys
5
- # GET signature key detail 403 response class.
6
- class GETSignatureKeyDetail403ResponseException < APIException
5
+ # Get signature key detail 403 response class.
6
+ class GetSignatureKeyDetail403ResponseException < APIException
7
7
  # TODO: Write general description for this method
8
8
  # @return [String]
9
9
  attr_accessor :message
@@ -2,8 +2,8 @@
2
2
  # ( https://apimatic.io ).
3
3
 
4
4
  module MessageMediaSigningKeys
5
- # GET signature key list 400 response class.
6
- class GETSignatureKeyList400ResponseException < APIException
5
+ # Get signature key list 400 response class.
6
+ class GetSignatureKeyList400ResponseException < APIException
7
7
  # TODO: Write general description for this method
8
8
  # @return [String]
9
9
  attr_accessor :message
@@ -2,8 +2,8 @@
2
2
  # ( https://apimatic.io ).
3
3
 
4
4
  module MessageMediaSigningKeys
5
- # GET signature key list 403 response class.
6
- class GETSignatureKeyList403ResponseException < APIException
5
+ # Get signature key list 403 response class.
6
+ class GetSignatureKeyList403ResponseException < APIException
7
7
  # TODO: Write general description for this method
8
8
  # @return [String]
9
9
  attr_accessor :message
@@ -2,8 +2,8 @@
2
2
  # ( https://apimatic.io ).
3
3
 
4
4
  module MessageMediaSigningKeys
5
- # GETSignatureKeyDetailResponse Model.
6
- class GETSignatureKeyDetailResponse < BaseModel
5
+ # GetSignatureKeyDetailResponse Model.
6
+ class GetSignatureKeyDetailResponse < BaseModel
7
7
  # TODO: Write general description for this method
8
8
  # @return [String]
9
9
  attr_accessor :key_id
@@ -59,7 +59,7 @@ module MessageMediaSigningKeys
59
59
  enabled = hash['enabled']
60
60
 
61
61
  # Create object from extracted values.
62
- GETSignatureKeyDetailResponse.new(key_id,
62
+ GetSignatureKeyDetailResponse.new(key_id,
63
63
  cipher,
64
64
  digest,
65
65
  created,
@@ -2,8 +2,8 @@
2
2
  # ( https://apimatic.io ).
3
3
 
4
4
  module MessageMediaSigningKeys
5
- # GETSignatureKeyListResponse Model.
6
- class GETSignatureKeyListResponse < BaseModel
5
+ # GetSignatureKeyListResponse Model.
6
+ class GetSignatureKeyListResponse < BaseModel
7
7
  # TODO: Write general description for this method
8
8
  # @return [String]
9
9
  attr_accessor :key_id
@@ -59,7 +59,7 @@ module MessageMediaSigningKeys
59
59
  enabled = hash['enabled']
60
60
 
61
61
  # Create object from extracted values.
62
- GETSignatureKeyListResponse.new(key_id,
62
+ GetSignatureKeyListResponse.new(key_id,
63
63
  cipher,
64
64
  digest,
65
65
  created,
@@ -0,0 +1,31 @@
1
+ # This file was automatically generated for MessageMedia by APIMATIC v2.0 ( https://apimatic.io ).
2
+
3
+ require 'json'
4
+ require 'test/unit'
5
+ require 'message_media_signing_keys.rb'
6
+ require_relative '../test_helper.rb'
7
+ require_relative '../http_response_catcher.rb'
8
+
9
+ class ControllerTestBase < Test::Unit::TestCase
10
+ include MessageMediaSigningKeys
11
+
12
+ class << self
13
+ attr_accessor :controller
14
+ end
15
+
16
+ # Called only once for a test class before any test has executed.
17
+ def self.startup
18
+ @@api_client = MessageMediaSigningKeysClient.new
19
+ @@request_timeout = 30
20
+ @@assert_precision = 0.01
21
+
22
+ Configuration.basic_auth_user_name = ENV['MessageMediaApiTestsKey']
23
+ Configuration.basic_auth_password = ENV['MessageMediaApiTestsSecret']
24
+ end
25
+
26
+ # Called once before every test case.
27
+ def setup
28
+ @response_catcher = HttpResponseCatcher.new
29
+ self.class.controller.http_call_back = @response_catcher
30
+ end
31
+ end
@@ -0,0 +1,35 @@
1
+ # This file was automatically generated for MessageMedia by APIMATIC v2.0 ( https://apimatic.io ).
2
+
3
+ require_relative 'controller_test_base'
4
+
5
+ class SignatureKeyManagementControllerTests < ControllerTestBase
6
+ # Called only once for the class before any test has executed
7
+ def self.startup
8
+ self.controller = @@api_client.signature_key_management
9
+ end
10
+
11
+ # Todo: Add description for test test_create_signature_key_test
12
+ def test_create_signature_key_test()
13
+ # Parameters for the API call
14
+ body = CreateSignatureKeyRequest.from_hash(JSON.parse('{"digest":"SHA224","cipher":"RSA"}'))
15
+
16
+ # Perform the API call through the SDK function
17
+ result = self.class.controller.create_signature_key(body)
18
+
19
+ # Test response code
20
+ assert_equal(@response_catcher.response.status_code, 201)
21
+
22
+ # Test whether the captured response is as we expected
23
+ assert_not_nil(result)
24
+ expected_body = JSON.parse(
25
+ '{"key_id":"7ca628a8-08b0-4e42-aeb8-960b37049c31","public_key":"MIGfMA0GCSq'\
26
+ 'GSIb3DQEBAQUAA4GNADCBiQKBgQCTIxtRyT5CuOD74r7UCT+AKzWNxvaAP9myjAqR7+vBnJKEvo'\
27
+ 'PnmbKTnm6uLlxutnMbjKrnCCWnQ9vtBVnnd+ElhwLDPADfMcJoOqwi7mTcxucckeEbBsfsgYRfd'\
28
+ 'acxgSZL8hVD1hLViQr3xwjEIkJcx1w3x8npvwMuTY0uW8+PjwIDAQAB","cipher":"RSA","di'\
29
+ 'gest":"SHA224","created":"2018-01-18T10:16:12.364Z","enabled":false}'
30
+ )
31
+ received_body = JSON.parse(@response_catcher.response.raw_body)
32
+ assert(TestHelper.match_body(expected_body, received_body))
33
+ end
34
+
35
+ end
@@ -0,0 +1,16 @@
1
+ # This file was automatically generated for MessageMedia by APIMATIC v2.0 ( https://apimatic.io ).
2
+
3
+ class HttpResponseCatcher < MessageMediaSigningKeys::HttpCallBack
4
+ attr_accessor :response
5
+
6
+ def on_before_request(request)
7
+ end
8
+
9
+ # Catching the response
10
+ def on_after_response(context)
11
+ @response = context.response
12
+ end
13
+ end
14
+
15
+
16
+
@@ -0,0 +1,91 @@
1
+ # This file was automatically generated for MessageMedia by APIMATIC v2.0 ( https://apimatic.io ).
2
+
3
+ require 'tempfile'
4
+ require 'open-uri'
5
+
6
+ class TestHelper
7
+
8
+ @cache = Hash.new
9
+
10
+ # Class method to compare the received headers with the expected headers.
11
+ # @param [Hash] A hash of expected headers (keys in lower case).
12
+ # @param [Hash] A hash of received headers.
13
+ # @param [Boolean, optional] A flag which determines if we allow extra headers.
14
+ def self.match_headers(expected_headers,
15
+ received_headers,
16
+ allow_extra: true)
17
+ return false if ((received_headers.length < expected_headers.length) ||
18
+ ((allow_extra == false) && (received_headers.length > expected_headers.length)))
19
+
20
+ received_headers = Hash[received_headers.map{|k, v| [k.to_s.downcase, v]}]
21
+ expected_headers.each do |e_key, e_value|
22
+ return false unless received_headers.key?(e_key)
23
+ return false if ((e_value != nil) &&
24
+ (e_value != received_headers[e_key]))
25
+ end
26
+
27
+ return true
28
+ end
29
+
30
+ # Class method to compare the received body with the expected body.
31
+ # @param [Dynamic] The expected body.
32
+ # @param [Dynamic] The received body.
33
+ # @param [Boolean, optional] A flag which determines if we check values in dictionaries.
34
+ # @param [Boolean, optional] A flag which determines if we check the order of array elements.
35
+ # @param [Boolean, optional] A flag which determines if we check the count of array elements.
36
+ def self.match_body(expected_body,
37
+ received_body,
38
+ check_values: false,
39
+ check_order: false,
40
+ check_count: false)
41
+ if expected_body.instance_of? Hash
42
+ return false unless received_body.instance_of? Hash
43
+ for key in expected_body.keys
44
+ return false unless received_body.keys.include? key
45
+ if check_values or expected_body[key].instance_of? Hash
46
+ return false unless TestHelper.match_body(expected_body[key],
47
+ received_body[key],
48
+ check_values: check_values,
49
+ check_order: check_order,
50
+ check_count: check_count)
51
+ end
52
+ end
53
+ elsif expected_body.instance_of? Array
54
+ return False unless received_body.instance_of? Array
55
+ if check_count == true && (expected_body.length != received_body.length)
56
+ return false
57
+ else
58
+ previous_matches = Array.new
59
+ expected_body.each.with_index do |expected_element, i|
60
+ matches = (received_body.map.with_index do |received_element, j|
61
+ j if TestHelper.match_body(expected_element,
62
+ received_element,
63
+ check_values: check_values,
64
+ check_order: check_order,
65
+ check_count: check_count)
66
+ end).compact
67
+ return false if matches.length == 0
68
+ if check_order == true
69
+ return false if (i != 0 && matches.map{|x| previous_matches.map{|y| y > x}.all?}.all?)
70
+ previous_matches = matches
71
+ end
72
+ end
73
+ end
74
+ elsif expected_body != received_body
75
+ return false
76
+ end
77
+ return true
78
+ end
79
+
80
+ # Class method which takes a URL, downloads the file (if not already downloaded
81
+ # for this test session) and returns the path of the file.
82
+ # @param [String] The URL of the required file.
83
+ def self.get_file(url)
84
+ unless @cache.keys.include? url
85
+ @cache[url] = Tempfile.new('APIMatic')
86
+ @cache[url].binmode
87
+ @cache[url].write(open(url, {ssl_ca_cert: Certifi.where}).read)
88
+ end
89
+ return @cache[url].path
90
+ end
91
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: messagemedia_signingkeys_sdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - MessageMedia Developers
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-06-27 00:00:00.000000000 Z
11
+ date: 2018-07-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: logging
@@ -92,9 +92,9 @@ dependencies:
92
92
  - - ">="
93
93
  - !ruby/object:Gem::Version
94
94
  version: 1.2.2
95
- description: The MessageMedia Signature Key API provides a number of endpoints for
96
- managing key used to sign each unique request to ensure security and the requests
97
- can't (easily) be spoofed. This is similar to using HMAC in your outbound messaging
95
+ description: The MessageMedia Signature Key API provides a number of endpoints for
96
+ managing key used to sign each unique request to ensure security and the requests
97
+ can't (easily) be spoofed. This is similar to using HMAC in your outbound messaging
98
98
  (rather than HTTP Basic).
99
99
  email: developers@messagemedia.com
100
100
  executables: []
@@ -137,6 +137,10 @@ files:
137
137
  - lib/message_media_signing_keys/models/get_enabled_signature_key_response.rb
138
138
  - lib/message_media_signing_keys/models/get_signature_key_detail_response.rb
139
139
  - lib/message_media_signing_keys/models/get_signature_key_list_response.rb
140
+ - test/controllers/controller_test_base.rb
141
+ - test/controllers/test_signature_key_management_controller.rb
142
+ - test/http_response_catcher.rb
143
+ - test/test_helper.rb
140
144
  homepage: https://developers.messagemedia.com
141
145
  licenses:
142
146
  - Apache-2.0
@@ -160,5 +164,5 @@ rubyforge_project:
160
164
  rubygems_version: 2.5.2
161
165
  signing_key:
162
166
  specification_version: 4
163
- summary: MessageMedia Signature Key Management SDK
167
+ summary: MessageMedia Signature Key Management API
164
168
  test_files: []