messagemedia_messages_sdk 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/LICENSE +201 -0
- data/README.md +608 -0
- data/lib/message_media_messages.rb +50 -0
- data/lib/message_media_messages/api_helper.rb +209 -0
- data/lib/message_media_messages/configuration.rb +29 -0
- data/lib/message_media_messages/controllers/base_controller.rb +57 -0
- data/lib/message_media_messages/controllers/delivery_reports_controller.rb +208 -0
- data/lib/message_media_messages/controllers/messages_controller.rb +336 -0
- data/lib/message_media_messages/controllers/replies_controller.rb +208 -0
- data/lib/message_media_messages/exceptions/api_exception.rb +18 -0
- data/lib/message_media_messages/http/auth/basic_auth.rb +20 -0
- data/lib/message_media_messages/http/faraday_client.rb +55 -0
- data/lib/message_media_messages/http/http_call_back.rb +22 -0
- data/lib/message_media_messages/http/http_client.rb +92 -0
- data/lib/message_media_messages/http/http_context.rb +18 -0
- data/lib/message_media_messages/http/http_method_enum.rb +11 -0
- data/lib/message_media_messages/http/http_request.rb +48 -0
- data/lib/message_media_messages/http/http_response.rb +21 -0
- data/lib/message_media_messages/message_media_messages_client.rb +39 -0
- data/lib/message_media_messages/models/base_model.rb +34 -0
- data/lib/message_media_messages/models/cancel_scheduled_message_request.rb +35 -0
- data/lib/message_media_messages/models/check_delivery_reports_response.rb +35 -0
- data/lib/message_media_messages/models/check_replies_response.rb +35 -0
- data/lib/message_media_messages/models/confirm_delivery_reports_as_received_request.rb +35 -0
- data/lib/message_media_messages/models/confirm_delivery_reports_as_received_request_11.rb +35 -0
- data/lib/message_media_messages/models/confirm_replies_as_received_request.rb +35 -0
- data/lib/message_media_messages/models/confirm_replies_as_received_request_8.rb +35 -0
- data/lib/message_media_messages/models/send_messages_request.rb +35 -0
- data/lib/message_media_messages/models/send_messages_response.rb +35 -0
- data/test/controllers/controller_test_base.rb +30 -0
- data/test/controllers/test_delivery_reports_controller.rb +131 -0
- data/test/controllers/test_messages_controller.rb +105 -0
- data/test/controllers/test_replies_controller.rb +132 -0
- data/test/http_response_catcher.rb +16 -0
- data/test/test_helper.rb +91 -0
- metadata +168 -0
@@ -0,0 +1,18 @@
|
|
1
|
+
# This file was automatically generated for MessageMedia by APIMATIC v2.0
|
2
|
+
# ( https://apimatic.io ).
|
3
|
+
|
4
|
+
module MessageMediaMessages
|
5
|
+
# Class for exceptions when there is a network error, status code error, etc.
|
6
|
+
class APIException < StandardError
|
7
|
+
attr_reader :context, :response_code
|
8
|
+
|
9
|
+
# The constructor.
|
10
|
+
# @param [String] The reason for raising an exception.
|
11
|
+
# @param [HttpContext] The HttpContext of the API call.
|
12
|
+
def initialize(reason, context)
|
13
|
+
super(reason)
|
14
|
+
@context = context
|
15
|
+
@response_code = context.response.status_code
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# This file was automatically generated for MessageMedia by APIMATIC v2.0
|
2
|
+
# ( https://apimatic.io ).
|
3
|
+
|
4
|
+
require 'base64'
|
5
|
+
|
6
|
+
module MessageMediaMessages
|
7
|
+
# Utility class for basic authorization.
|
8
|
+
class BasicAuth
|
9
|
+
# Add basic authentication to the request.
|
10
|
+
# @param [HttpRequest] The HttpRequest object to which authentication will
|
11
|
+
# be added.
|
12
|
+
def self.apply(http_request)
|
13
|
+
username = Configuration.basic_auth_user_name
|
14
|
+
password = Configuration.basic_auth_password
|
15
|
+
value = Base64.strict_encode64("#{username}:#{password}")
|
16
|
+
header_value = "Basic #{value}"
|
17
|
+
http_request.headers['Authorization'] = header_value
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
# This file was automatically generated for MessageMedia by APIMATIC v2.0
|
2
|
+
# ( https://apimatic.io ).
|
3
|
+
require 'faraday/http_cache'
|
4
|
+
|
5
|
+
module MessageMediaMessages
|
6
|
+
# An implementation of HttpClient.
|
7
|
+
class FaradayClient < HttpClient
|
8
|
+
# The constructor.
|
9
|
+
def initialize(timeout: nil, cache: false,
|
10
|
+
max_retries: nil, retry_interval: nil)
|
11
|
+
@connection = Faraday.new do |faraday|
|
12
|
+
faraday.use Faraday::HttpCache, serializer: Marshal if cache
|
13
|
+
faraday.request :multipart
|
14
|
+
faraday.request :url_encoded
|
15
|
+
faraday.ssl[:ca_file] = Certifi.where
|
16
|
+
faraday.adapter Faraday.default_adapter
|
17
|
+
faraday.options[:params_encoder] = Faraday::FlatParamsEncoder
|
18
|
+
faraday.options[:open_timeout] = timeout if timeout
|
19
|
+
faraday.request :retry, max: max_retries, interval: if max_retries &&
|
20
|
+
retry_interval
|
21
|
+
retry_interval
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
# Method overridden from HttpClient.
|
27
|
+
def execute_as_string(http_request)
|
28
|
+
response = @connection.send(
|
29
|
+
http_request.http_method.downcase,
|
30
|
+
http_request.query_url
|
31
|
+
) do |request|
|
32
|
+
request.headers = http_request.headers
|
33
|
+
request.body = http_request.parameters
|
34
|
+
end
|
35
|
+
convert_response(response)
|
36
|
+
end
|
37
|
+
|
38
|
+
# Method overridden from HttpClient.
|
39
|
+
def execute_as_binary(http_request)
|
40
|
+
response = @connection.send(
|
41
|
+
http_request.http_method.downcase,
|
42
|
+
http_request.query_url
|
43
|
+
) do |request|
|
44
|
+
request.headers = http_request.headers
|
45
|
+
request.body = http_request.parameters
|
46
|
+
end
|
47
|
+
convert_response(response)
|
48
|
+
end
|
49
|
+
|
50
|
+
# Method overridden from HttpClient.
|
51
|
+
def convert_response(response)
|
52
|
+
HttpResponse.new(response.status, response.headers, response.body)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# This file was automatically generated for MessageMedia by APIMATIC v2.0
|
2
|
+
# ( https://apimatic.io ).
|
3
|
+
|
4
|
+
module MessageMediaMessages
|
5
|
+
# HttpCallBack allows defining callables for pre and post API calls.
|
6
|
+
class HttpCallBack
|
7
|
+
# A controller will call this method before making an HTTP Request.
|
8
|
+
# @param [HttpRequest] The HttpRequest object which the HttpClient
|
9
|
+
# will execute.
|
10
|
+
def on_before_request(_http_request)
|
11
|
+
raise NotImplementedError, 'This method needs
|
12
|
+
to be implemented in a child class.'
|
13
|
+
end
|
14
|
+
|
15
|
+
# A controller will call this method after making an HTTP Request.
|
16
|
+
# @param [HttpContext] The HttpContext of the API call.
|
17
|
+
def on_after_response(_http_context)
|
18
|
+
raise NotImplementedError, 'This method needs
|
19
|
+
to be implemented in a child class.'
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,92 @@
|
|
1
|
+
# This file was automatically generated for MessageMedia by APIMATIC v2.0
|
2
|
+
# ( https://apimatic.io ).
|
3
|
+
|
4
|
+
module MessageMediaMessages
|
5
|
+
# An interface for the methods that an HTTP Client must implement.
|
6
|
+
#
|
7
|
+
# This class should not be instantiated but should be used as a base class
|
8
|
+
# for HTTP Client classes.
|
9
|
+
class HttpClient
|
10
|
+
# Execute an HttpRequest when the response is expected to be a string.
|
11
|
+
# @param [HttpRequest] The HttpRequest to be executed.
|
12
|
+
def execute_as_string(_http_request)
|
13
|
+
raise NotImplementedError, 'This method needs
|
14
|
+
to be implemented in a child class.'
|
15
|
+
end
|
16
|
+
|
17
|
+
# Execute an HttpRequest when the response is expected to be binary.
|
18
|
+
# @param [HttpRequest] The HttpRequest to be executed.
|
19
|
+
def execute_as_binary(_http_request)
|
20
|
+
raise NotImplementedError, 'This method needs
|
21
|
+
to be implemented in a child class.'
|
22
|
+
end
|
23
|
+
|
24
|
+
# Converts the HTTP Response from the client to an HttpResponse object.
|
25
|
+
# @param [Dynamic] The response object received from the client.
|
26
|
+
def convert_response(_response)
|
27
|
+
raise NotImplementedError, 'This method needs
|
28
|
+
to be implemented in a child class.'
|
29
|
+
end
|
30
|
+
|
31
|
+
# Get a GET HttpRequest object.
|
32
|
+
# @param [String] The URL to send the request to.
|
33
|
+
# @param [Hash, Optional] The headers for the HTTP Request.
|
34
|
+
def get(query_url,
|
35
|
+
headers: {})
|
36
|
+
HttpRequest.new(HttpMethodEnum::GET,
|
37
|
+
query_url,
|
38
|
+
headers: headers)
|
39
|
+
end
|
40
|
+
|
41
|
+
# Get a POST HttpRequest object.
|
42
|
+
# @param [String] The URL to send the request to.
|
43
|
+
# @param [Hash, Optional] The headers for the HTTP Request.
|
44
|
+
# @param [Hash, Optional] The parameters for the HTTP Request.
|
45
|
+
def post(query_url,
|
46
|
+
headers: {},
|
47
|
+
parameters: {})
|
48
|
+
HttpRequest.new(HttpMethodEnum::POST,
|
49
|
+
query_url,
|
50
|
+
headers: headers,
|
51
|
+
parameters: parameters)
|
52
|
+
end
|
53
|
+
|
54
|
+
# Get a PUT HttpRequest object.
|
55
|
+
# @param [String] The URL to send the request to.
|
56
|
+
# @param [Hash, Optional] The headers for the HTTP Request.
|
57
|
+
# @param [Hash, Optional] The parameters for the HTTP Request.
|
58
|
+
def put(query_url,
|
59
|
+
headers: {},
|
60
|
+
parameters: {})
|
61
|
+
HttpRequest.new(HttpMethodEnum::PUT,
|
62
|
+
query_url,
|
63
|
+
headers: headers,
|
64
|
+
parameters: parameters)
|
65
|
+
end
|
66
|
+
|
67
|
+
# Get a PATCH HttpRequest object.
|
68
|
+
# @param [String] The URL to send the request to.
|
69
|
+
# @param [Hash, Optional] The headers for the HTTP Request.
|
70
|
+
# @param [Hash, Optional] The parameters for the HTTP Request.
|
71
|
+
def patch(query_url,
|
72
|
+
headers: {},
|
73
|
+
parameters: {})
|
74
|
+
HttpRequest.new(HttpMethodEnum::PATCH,
|
75
|
+
query_url,
|
76
|
+
headers: headers,
|
77
|
+
parameters: parameters)
|
78
|
+
end
|
79
|
+
|
80
|
+
# Get a DELETE HttpRequest object.
|
81
|
+
# @param [String] The URL to send the request to.
|
82
|
+
# @param [Hash, Optional] The headers for the HTTP Request.
|
83
|
+
def delete(query_url,
|
84
|
+
headers: {},
|
85
|
+
parameters: {})
|
86
|
+
HttpRequest.new(HttpMethodEnum::DELETE,
|
87
|
+
query_url,
|
88
|
+
headers: headers,
|
89
|
+
parameters: parameters)
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# This file was automatically generated for MessageMedia by APIMATIC v2.0
|
2
|
+
# ( https://apimatic.io ).
|
3
|
+
|
4
|
+
module MessageMediaMessages
|
5
|
+
# Represents an Http call in context.
|
6
|
+
class HttpContext
|
7
|
+
attr_accessor :request, :response
|
8
|
+
|
9
|
+
# The constructor.
|
10
|
+
# @param [HttpRequest] An HttpRequest object representing the HTTP request.
|
11
|
+
# @param [HttpResponse] An HttpResponse object representing the HTTP
|
12
|
+
# response.
|
13
|
+
def initialize(request, response)
|
14
|
+
@request = request
|
15
|
+
@response = response
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
# This file was automatically generated for MessageMedia by APIMATIC v2.0
|
2
|
+
# ( https://apimatic.io ).
|
3
|
+
|
4
|
+
module MessageMediaMessages
|
5
|
+
# HTTP Methods Enumeration.
|
6
|
+
class HttpMethodEnum
|
7
|
+
HTTPMETHODENUM = [GET = 'GET'.freeze, POST = 'POST'.freeze,
|
8
|
+
PUT = 'PUT'.freeze, PATCH = 'PATCH'.freeze,
|
9
|
+
DELETE = 'DELETE'.freeze].freeze
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
# This file was automatically generated for MessageMedia by APIMATIC v2.0
|
2
|
+
# ( https://apimatic.io ).
|
3
|
+
|
4
|
+
module MessageMediaMessages
|
5
|
+
# Represents a single Http Request.
|
6
|
+
class HttpRequest
|
7
|
+
attr_accessor :http_method, :query_url, :headers,
|
8
|
+
:parameters, :username, :password
|
9
|
+
|
10
|
+
# The constructor.
|
11
|
+
# @param [HttpMethodEnum] The HTTP method.
|
12
|
+
# @param [String] The URL to send the request to.
|
13
|
+
# @param [Hash, Optional] The headers for the HTTP Request.
|
14
|
+
# @param [Hash, Optional] The parameters for the HTTP Request.
|
15
|
+
def initialize(http_method,
|
16
|
+
query_url,
|
17
|
+
headers: {},
|
18
|
+
parameters: {})
|
19
|
+
@http_method = http_method
|
20
|
+
@query_url = query_url
|
21
|
+
@headers = headers
|
22
|
+
@parameters = parameters
|
23
|
+
end
|
24
|
+
|
25
|
+
# Add a header to the HttpRequest.
|
26
|
+
# @param [String] The name of the header.
|
27
|
+
# @param [String] The value of the header.
|
28
|
+
def add_header(name, value)
|
29
|
+
@headers[name] = value
|
30
|
+
end
|
31
|
+
|
32
|
+
# Add a parameter to the HttpRequest.
|
33
|
+
# @param [String] The name of the parameter.
|
34
|
+
# @param [String] The value of the parameter.
|
35
|
+
def add_parameter(name, value)
|
36
|
+
@parameters[name] = value
|
37
|
+
end
|
38
|
+
|
39
|
+
# Add a query parameter to the HttpRequest.
|
40
|
+
# @param [String] The name of the query parameter.
|
41
|
+
# @param [String] The value of the query parameter.
|
42
|
+
def add_query_parameter(name, value)
|
43
|
+
@query_url = APIHelper.append_url_with_query_parameters(@query_url,
|
44
|
+
name => value)
|
45
|
+
@query_url = APIHelper.clean_url(@query_url)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# This file was automatically generated for MessageMedia by APIMATIC v2.0
|
2
|
+
# ( https://apimatic.io ).
|
3
|
+
|
4
|
+
module MessageMediaMessages
|
5
|
+
# Http response received.
|
6
|
+
class HttpResponse
|
7
|
+
attr_accessor :status_code, :headers, :raw_body
|
8
|
+
|
9
|
+
# The constructor
|
10
|
+
# @param [Integer] The status code returned by the server.
|
11
|
+
# @param [Hash] The headers sent by the server in the response.
|
12
|
+
# @param [String] The raw body of the response.
|
13
|
+
def initialize(status_code,
|
14
|
+
headers,
|
15
|
+
raw_body)
|
16
|
+
@status_code = status_code
|
17
|
+
@headers = headers
|
18
|
+
@raw_body = raw_body
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# This file was automatically generated for MessageMedia by APIMATIC v2.0
|
2
|
+
# ( https://apimatic.io ).
|
3
|
+
|
4
|
+
module MessageMediaMessages
|
5
|
+
# message_media_messages client class.
|
6
|
+
class MessageMediaMessagesClient
|
7
|
+
# Singleton access to messages controller.
|
8
|
+
# @return [MessagesController] Returns the controller instance.
|
9
|
+
def messages
|
10
|
+
MessagesController.instance
|
11
|
+
end
|
12
|
+
|
13
|
+
# Singleton access to delivery_reports controller.
|
14
|
+
# @return [DeliveryReportsController] Returns the controller instance.
|
15
|
+
def delivery_reports
|
16
|
+
DeliveryReportsController.instance
|
17
|
+
end
|
18
|
+
|
19
|
+
# Singleton access to replies controller.
|
20
|
+
# @return [RepliesController] Returns the controller instance.
|
21
|
+
def replies
|
22
|
+
RepliesController.instance
|
23
|
+
end
|
24
|
+
|
25
|
+
# Returns the configuration class for easy access.
|
26
|
+
# @return [Configuration] Returns the actual configuration class.
|
27
|
+
def config
|
28
|
+
Configuration
|
29
|
+
end
|
30
|
+
|
31
|
+
# Initializer with authentication and configuration parameters.
|
32
|
+
def initialize(basic_auth_user_name: nil, basic_auth_password: nil)
|
33
|
+
Configuration.basic_auth_user_name = basic_auth_user_name if
|
34
|
+
basic_auth_user_name
|
35
|
+
Configuration.basic_auth_password = basic_auth_password if
|
36
|
+
basic_auth_password
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# This file was automatically generated for MessageMedia by APIMATIC v2.0
|
2
|
+
# ( https://apimatic.io ).
|
3
|
+
|
4
|
+
module MessageMediaMessages
|
5
|
+
# Base model.
|
6
|
+
class BaseModel
|
7
|
+
# Returns a Hash representation of the current object.
|
8
|
+
def to_hash
|
9
|
+
hash = {}
|
10
|
+
instance_variables.each do |name|
|
11
|
+
value = instance_variable_get(name)
|
12
|
+
name = name[1..-1]
|
13
|
+
key = self.class.names.key?(name) ? self.class.names[name] : name
|
14
|
+
if value.instance_of? Array
|
15
|
+
hash[key] = value.map { |v| v.is_a?(BaseModel) ? v.to_hash : v }
|
16
|
+
elsif value.instance_of? Hash
|
17
|
+
hash[key] = {}
|
18
|
+
value.each do |k, v|
|
19
|
+
hash[key][k] = v.is_a?(BaseModel) ? v.to_hash : v
|
20
|
+
end
|
21
|
+
else
|
22
|
+
hash[key] = value.is_a?(BaseModel) ? value.to_hash : value
|
23
|
+
end
|
24
|
+
end
|
25
|
+
hash
|
26
|
+
end
|
27
|
+
|
28
|
+
# Returns a JSON representation of the curent object.
|
29
|
+
def to_json(options = {})
|
30
|
+
hash = to_hash
|
31
|
+
hash.to_json(options)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# This file was automatically generated for MessageMedia by APIMATIC v2.0
|
2
|
+
# ( https://apimatic.io ).
|
3
|
+
|
4
|
+
module MessageMediaMessages
|
5
|
+
# CancelScheduledMessageRequest Model.
|
6
|
+
class CancelScheduledMessageRequest < BaseModel
|
7
|
+
# TODO: Write general description for this method
|
8
|
+
# @return [String]
|
9
|
+
attr_accessor :status
|
10
|
+
|
11
|
+
# A mapping from model property names to API property names.
|
12
|
+
def self.names
|
13
|
+
if @_hash.nil?
|
14
|
+
@_hash = {}
|
15
|
+
@_hash['status'] = 'status'
|
16
|
+
end
|
17
|
+
@_hash
|
18
|
+
end
|
19
|
+
|
20
|
+
def initialize(status = nil)
|
21
|
+
@status = status
|
22
|
+
end
|
23
|
+
|
24
|
+
# Creates an instance of the object from a hash.
|
25
|
+
def self.from_hash(hash)
|
26
|
+
return nil unless hash
|
27
|
+
|
28
|
+
# Extract variables from the hash.
|
29
|
+
status = hash['status']
|
30
|
+
|
31
|
+
# Create object from extracted values.
|
32
|
+
CancelScheduledMessageRequest.new(status)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# This file was automatically generated for MessageMedia by APIMATIC v2.0
|
2
|
+
# ( https://apimatic.io ).
|
3
|
+
|
4
|
+
module MessageMediaMessages
|
5
|
+
# CheckDeliveryReportsResponse Model.
|
6
|
+
class CheckDeliveryReportsResponse < BaseModel
|
7
|
+
# TODO: Write general description for this method
|
8
|
+
# @return [List of Object]
|
9
|
+
attr_accessor :delivery_reports
|
10
|
+
|
11
|
+
# A mapping from model property names to API property names.
|
12
|
+
def self.names
|
13
|
+
if @_hash.nil?
|
14
|
+
@_hash = {}
|
15
|
+
@_hash['delivery_reports'] = 'delivery_reports'
|
16
|
+
end
|
17
|
+
@_hash
|
18
|
+
end
|
19
|
+
|
20
|
+
def initialize(delivery_reports = nil)
|
21
|
+
@delivery_reports = delivery_reports
|
22
|
+
end
|
23
|
+
|
24
|
+
# Creates an instance of the object from a hash.
|
25
|
+
def self.from_hash(hash)
|
26
|
+
return nil unless hash
|
27
|
+
|
28
|
+
# Extract variables from the hash.
|
29
|
+
delivery_reports = hash['delivery_reports']
|
30
|
+
|
31
|
+
# Create object from extracted values.
|
32
|
+
CheckDeliveryReportsResponse.new(delivery_reports)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|