messagemedia_lookups_sdk 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/LICENSE +0 -0
- data/README.md +102 -42
- data/lib/message_media_lookups.rb +0 -0
- data/lib/message_media_lookups/api_helper.rb +0 -0
- data/lib/message_media_lookups/configuration.rb +0 -0
- data/lib/message_media_lookups/controllers/base_controller.rb +0 -0
- data/lib/message_media_lookups/controllers/lookups_controller.rb +0 -0
- data/lib/message_media_lookups/exceptions/api_exception.rb +0 -0
- data/lib/message_media_lookups/http/auth/basic_auth.rb +0 -0
- data/lib/message_media_lookups/http/auth/hmac_auth.rb +52 -52
- data/lib/message_media_lookups/http/faraday_client.rb +0 -0
- data/lib/message_media_lookups/http/http_call_back.rb +0 -0
- data/lib/message_media_lookups/http/http_client.rb +0 -0
- data/lib/message_media_lookups/http/http_context.rb +0 -0
- data/lib/message_media_lookups/http/http_method_enum.rb +0 -0
- data/lib/message_media_lookups/http/http_request.rb +0 -0
- data/lib/message_media_lookups/http/http_response.rb +0 -0
- data/lib/message_media_lookups/message_media_lookups_client.rb +0 -0
- data/lib/message_media_lookups/models/base_model.rb +0 -0
- data/lib/message_media_lookups/models/lookup_a_phone_number_response.rb +0 -0
- data/test/controllers/controller_test_base.rb +0 -0
- data/test/controllers/test_lookups_controller.rb +0 -0
- data/test/http_response_catcher.rb +0 -0
- data/test/test_helper.rb +0 -0
- metadata +7 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: a17f807e557fb990af27aaec864c128cb449293b0b735940947ad528c4b1840f
|
4
|
+
data.tar.gz: '034387f95f95045ab1bfcee4e69dcc500828d2e4d51dafaaecacf4512063d8b7'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 99f7306b445d6e598de46bcaefc28e27b0911c5d6ab6ec2d8e1367d5135c743a70d2ab83c4f11532c763d4fd14c8764d865bfca6d0ccdd66898db309ee8b5d51
|
7
|
+
data.tar.gz: 3c665abfa7807666ad3c4be7b3ff9602cf3f62e6c5ad8b2cc89b90ea26d2e3224913bbfceb9ad233494e9e784c53f2d6503273c376141dc31a582729360ad6dc
|
data/LICENSE
CHANGED
File without changes
|
data/README.md
CHANGED
@@ -1,42 +1,102 @@
|
|
1
|
-
# MessageMedia Lookups Ruby SDK
|
2
|
-
[![Build Status](https://travis-ci.org/messagemedia/lookups-ruby-sdk.svg?branch=master)](https://travis-ci.org/messagemedia/lookups-ruby-sdk)
|
3
|
-
[![
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
1
|
+
# MessageMedia Lookups Ruby SDK
|
2
|
+
[![Build Status](https://travis-ci.org/messagemedia/lookups-ruby-sdk.svg?branch=master)](https://travis-ci.org/messagemedia/lookups-ruby-sdk)
|
3
|
+
[![Pull Requests Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat)](http://makeapullrequest.com)
|
4
|
+
[![Gem Version](https://badge.fury.io/rb/messagemedia_lookups_sdk.svg)](https://badge.fury.io/rb/messagemedia_lookups_sdk)
|
5
|
+
|
6
|
+
The MessageMedia Lookups API provides a number of endpoints for validating the phone numbers you’re sending to by checking their validity, type and carrier records.
|
7
|
+
|
8
|
+
![Isometric](https://developers.messagemedia.com/wp-content/uploads/2017/11/lookups-api.png)
|
9
|
+
|
10
|
+
## Table of Contents
|
11
|
+
* [Authentication](#closed_lock_with_key-authentication)
|
12
|
+
* [Errors](#interrobang-errors)
|
13
|
+
* [Information](#newspaper-information)
|
14
|
+
* [Slack and Mailing List](#slack-and-mailing-list)
|
15
|
+
* [Bug Reports](#bug-reports)
|
16
|
+
* [Contributing](#contributing)
|
17
|
+
* [Installation](#star-installation)
|
18
|
+
* [Get Started](#clapper-get-started)
|
19
|
+
* [API Documentation](#closed_book-api-documentation)
|
20
|
+
* [Need help?](#confused-need-help)
|
21
|
+
* [License](#page_with_curl-license)
|
22
|
+
|
23
|
+
## :closed_lock_with_key: Authentication
|
24
|
+
|
25
|
+
Authentication is done via API keys. Sign up at https://developers.messagemedia.com/register/ to get your API keys.
|
26
|
+
|
27
|
+
Requests are authenticated using HTTP Basic Auth or HMAC. Provide your API key as the auth_user_name and API secret as the auth_password.
|
28
|
+
|
29
|
+
## :interrobang: Errors
|
30
|
+
|
31
|
+
Our API returns standard HTTP success or error status codes. For errors, we will also include extra information about what went wrong encoded in the response as JSON. The most common status codes are listed below.
|
32
|
+
|
33
|
+
#### HTTP Status Codes
|
34
|
+
|
35
|
+
| Code | Title | Description |
|
36
|
+
|-----------|-------------|-------------|
|
37
|
+
| 400 | Invalid Request | The request was invalid |
|
38
|
+
| 401 | Unauthorized | Your API credentials are invalid |
|
39
|
+
| 403 | Disabled feature | Feature not enabled |
|
40
|
+
| 404 | Not Found | The resource does not exist |
|
41
|
+
| 50X | Internal Server Error | An error occurred with our API |
|
42
|
+
|
43
|
+
## :newspaper: Information
|
44
|
+
|
45
|
+
#### Slack and Mailing List
|
46
|
+
|
47
|
+
If you have any questions, comments, or concerns, please join our Slack channel:
|
48
|
+
https://developers.messagemedia.com/collaborate/slack/
|
49
|
+
|
50
|
+
Alternatively you can email us at:
|
51
|
+
developers@messagemedia.com
|
52
|
+
|
53
|
+
#### Bug reports
|
54
|
+
|
55
|
+
If you discover a problem with the SDK, we would like to know about it. You can raise an [issue](https://github.com/messagemedia/signingkeys-nodejs-sdk/issues) or send an email to: developers@messagemedia.com
|
56
|
+
|
57
|
+
#### Contributing
|
58
|
+
|
59
|
+
We welcome your thoughts on how we could best provide you with SDKs that would simplify how you consume our services in your application. You can fork and create pull requests for any features you would like to see or raise an [issue](https://github.com/messagemedia/signingkeys-nodejs-sdk/issues)
|
60
|
+
|
61
|
+
|
62
|
+
## :star: Installation
|
63
|
+
Run the following command to install the SDK via RubyGems:
|
64
|
+
```
|
65
|
+
gem install messagemedia_lookups
|
66
|
+
```
|
67
|
+
|
68
|
+
## :clapper: Get Started
|
69
|
+
It's easy to get started. Simply enter the API Key and secret you obtained from the [MessageMedia Developers Portal](https://developers.messagemedia.com) into the code snippet below and a mobile number you wish to send to.
|
70
|
+
|
71
|
+
### Lookup a number
|
72
|
+
```ruby
|
73
|
+
require 'message_media_lookups'
|
74
|
+
|
75
|
+
# Configuration parameters and credentials
|
76
|
+
auth_user_name = 'YOUR_API_KEY' # The username to use with basic/HMAC authentication
|
77
|
+
auth_password = 'YOUR_SECRET_KEY' # The password to use with basic/HMAC authentication
|
78
|
+
use_hmac = false # Change this to true if you are using HMAC keys
|
79
|
+
|
80
|
+
client = MessageMediaLookups::MessageMediaLookupsClient.new(
|
81
|
+
auth_user_name: auth_user_name,
|
82
|
+
auth_password: auth_password,
|
83
|
+
use_hmac: use_hmac
|
84
|
+
)
|
85
|
+
|
86
|
+
lookups_controller = client.lookups
|
87
|
+
|
88
|
+
phone_number = 'YOUR_MOBILE_NUMBER'
|
89
|
+
options = 'carrier,type'
|
90
|
+
|
91
|
+
result = lookups_controller.get_lookup_a_phone_number(phone_number, options)
|
92
|
+
print result.inspect
|
93
|
+
```
|
94
|
+
|
95
|
+
## :closed_book: API Reference Documentation
|
96
|
+
Check out the [full API documentation](https://developers.messagemedia.com/code/lookups-api-documentation/) for more detailed information.
|
97
|
+
|
98
|
+
## :confused: Need help?
|
99
|
+
Please contact developer support at developers@messagemedia.com or check out the developer portal at [developers.messagemedia.com](https://developers.messagemedia.com/)
|
100
|
+
|
101
|
+
## :page_with_curl: License
|
102
|
+
Apache License. See the [LICENSE](LICENSE) file.
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -1,52 +1,52 @@
|
|
1
|
-
|
2
|
-
require 'base64'
|
3
|
-
|
4
|
-
module MessageMediaMessages
|
5
|
-
# Utility class for basic authorization.
|
6
|
-
class HmacAuth
|
7
|
-
def self.create_signature(date, content_signature, url, body=nil)
|
8
|
-
request_type = "GET"
|
9
|
-
|
10
|
-
if body != nil
|
11
|
-
request_type = "POST"
|
12
|
-
end
|
13
|
-
|
14
|
-
signing_string = "date: #{date}\n#{content_signature}#{request_type} #{url} HTTP/1.1"
|
15
|
-
hmac = OpenSSL::HMAC.digest(OpenSSL::Digest::Digest.new('sha1'), Configuration.hmac_auth_password.encode("ASCII"), signing_string.encode("ASCII"))
|
16
|
-
|
17
|
-
return Base64.encode64(hmac).chomp
|
18
|
-
end
|
19
|
-
|
20
|
-
# Add basic authentication to the request.
|
21
|
-
# @param [HttpRequest] The HttpRequest object to which authentication will
|
22
|
-
# be added.
|
23
|
-
def self.apply(http_request, url=nil, body=nil)
|
24
|
-
username = Configuration.hmac_auth_user_name
|
25
|
-
|
26
|
-
content_signature = ""
|
27
|
-
content_header = ""
|
28
|
-
|
29
|
-
now = DateTime.now.new_offset(0).to_time.strftime("%a, %d %b %Y %H:%M:%S GMT")
|
30
|
-
|
31
|
-
date_header = now
|
32
|
-
|
33
|
-
if body != nil
|
34
|
-
md5 = Digest::MD5.new
|
35
|
-
md5.update(body)
|
36
|
-
|
37
|
-
content_hash = md5.hexdigest
|
38
|
-
content_signature = "x-Content-MD5: #{content_hash}\n"
|
39
|
-
content_header = "x-Content-MD5 "
|
40
|
-
http_request.headers["x-Content-MD5"] = content_hash
|
41
|
-
end
|
42
|
-
|
43
|
-
http_request.headers["date"] = date_header
|
44
|
-
|
45
|
-
hmac_signature = HmacAuth.create_signature(date_header, content_signature, url, body)
|
46
|
-
|
47
|
-
joined = "username=\"#{username}\", algorithm=\"hmac-sha1\", headers=\"date #{content_header}request-line\", signature=\"#{hmac_signature}\""
|
48
|
-
header_value = "hmac #{joined}"
|
49
|
-
http_request.headers["Authorization"] = header_value
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
1
|
+
|
2
|
+
require 'base64'
|
3
|
+
|
4
|
+
module MessageMediaMessages
|
5
|
+
# Utility class for basic authorization.
|
6
|
+
class HmacAuth
|
7
|
+
def self.create_signature(date, content_signature, url, body=nil)
|
8
|
+
request_type = "GET"
|
9
|
+
|
10
|
+
if body != nil
|
11
|
+
request_type = "POST"
|
12
|
+
end
|
13
|
+
|
14
|
+
signing_string = "date: #{date}\n#{content_signature}#{request_type} #{url} HTTP/1.1"
|
15
|
+
hmac = OpenSSL::HMAC.digest(OpenSSL::Digest::Digest.new('sha1'), Configuration.hmac_auth_password.encode("ASCII"), signing_string.encode("ASCII"))
|
16
|
+
|
17
|
+
return Base64.encode64(hmac).chomp
|
18
|
+
end
|
19
|
+
|
20
|
+
# Add basic authentication to the request.
|
21
|
+
# @param [HttpRequest] The HttpRequest object to which authentication will
|
22
|
+
# be added.
|
23
|
+
def self.apply(http_request, url=nil, body=nil)
|
24
|
+
username = Configuration.hmac_auth_user_name
|
25
|
+
|
26
|
+
content_signature = ""
|
27
|
+
content_header = ""
|
28
|
+
|
29
|
+
now = DateTime.now.new_offset(0).to_time.strftime("%a, %d %b %Y %H:%M:%S GMT")
|
30
|
+
|
31
|
+
date_header = now
|
32
|
+
|
33
|
+
if body != nil
|
34
|
+
md5 = Digest::MD5.new
|
35
|
+
md5.update(body)
|
36
|
+
|
37
|
+
content_hash = md5.hexdigest
|
38
|
+
content_signature = "x-Content-MD5: #{content_hash}\n"
|
39
|
+
content_header = "x-Content-MD5 "
|
40
|
+
http_request.headers["x-Content-MD5"] = content_hash
|
41
|
+
end
|
42
|
+
|
43
|
+
http_request.headers["date"] = date_header
|
44
|
+
|
45
|
+
hmac_signature = HmacAuth.create_signature(date_header, content_signature, url, body)
|
46
|
+
|
47
|
+
joined = "username=\"#{username}\", algorithm=\"hmac-sha1\", headers=\"date #{content_header}request-line\", signature=\"#{hmac_signature}\""
|
48
|
+
header_value = "hmac #{joined}"
|
49
|
+
http_request.headers["Authorization"] = header_value
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
data/test/test_helper.rb
CHANGED
File without changes
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: messagemedia_lookups_sdk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- MessageMedia Developers
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-01-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: logging
|
@@ -28,16 +28,16 @@ dependencies:
|
|
28
28
|
name: faraday
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 0.10
|
33
|
+
version: '0.10'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 0.10
|
40
|
+
version: '0.10'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: test-unit
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -150,8 +150,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
150
150
|
- !ruby/object:Gem::Version
|
151
151
|
version: '0'
|
152
152
|
requirements: []
|
153
|
-
|
154
|
-
rubygems_version: 2.5.2
|
153
|
+
rubygems_version: 3.0.3
|
155
154
|
signing_key:
|
156
155
|
specification_version: 4
|
157
156
|
summary: MessageMedia Lookups SDK
|