Class: MessageApi
- Inherits:
-
Object
- Object
- MessageApi
- Includes:
- Validation
- Defined in:
- lib/tacklebox/apis/message_api.rb
Instance Attribute Summary collapse
-
#base_url ⇒ Object
Returns the value of attribute base_url.
-
#http_client ⇒ Object
Returns the value of attribute http_client.
Instance Method Summary collapse
- #get_message(service_id, user_id, message_id) ⇒ Object
-
#initialize(config) ⇒ MessageApi
constructor
A new instance of MessageApi.
- #list_messages(service_id, user_id) ⇒ Object
- #resend_message(service_id, user_id, message_id) ⇒ Object
Methods included from Validation
#is_valid_data, #is_valid_event_data, #is_valid_id, #is_valid_name, #is_valid_subscription_data
Constructor Details
#initialize(config) ⇒ MessageApi
Returns a new instance of MessageApi.
10 11 12 13 |
# File 'lib/tacklebox/apis/message_api.rb', line 10 def initialize(config) self.base_url = config[:base_url] self.http_client = HttpClient.new(config[:api_key]) end |
Instance Attribute Details
#base_url ⇒ Object
Returns the value of attribute base_url.
8 9 10 |
# File 'lib/tacklebox/apis/message_api.rb', line 8 def base_url @base_url end |
#http_client ⇒ Object
Returns the value of attribute http_client.
8 9 10 |
# File 'lib/tacklebox/apis/message_api.rb', line 8 def http_client @http_client end |
Instance Method Details
#get_message(service_id, user_id, message_id) ⇒ Object
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/tacklebox/apis/message_api.rb', line 59 def (service_id, user_id, ) if !self.is_valid_id(service_id) return new_error( ERROR_TYPES['missing_parameter'], "The get_message method must be invoked with a non-empty string service_id argument." ) end if !self.is_valid_id(user_id) return new_error( ERROR_TYPES['missing_parameter'], "The get_message method must be invoked with a non-empty string user_id argument." ) end if !self.is_valid_id() return new_error( ERROR_TYPES['missing_parameter'], "The get_message method must be invoked with a non-empty string message_id argument." ) end path = "services/#{service_id}/users/#{user_id}/messages/#{}" request = HttpRequest.new("GET", @base_url, path) @http_client.send(request) end |
#list_messages(service_id, user_id) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/tacklebox/apis/message_api.rb', line 15 def (service_id, user_id) if !self.is_valid_id(service_id) return new_error( ERROR_TYPES['missing_parameter'], "The list_messages method must be invoked with a non-empty string service_id argument." ) end if !self.is_valid_id(user_id) return new_error( ERROR_TYPES['missing_parameter'], "The list_messages method must be invoked with a non-empty string user_id argument." ) end path = "services/#{service_id}/users/#{user_id}/messages" request = HttpRequest.new("GET", @base_url, path) @http_client.send(request) end |
#resend_message(service_id, user_id, message_id) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/tacklebox/apis/message_api.rb', line 34 def (service_id, user_id, ) if !self.is_valid_id(service_id) return new_error( ERROR_TYPES['missing_parameter'], "The resend_message method must be invoked with a non-empty string service_id argument." ) end if !self.is_valid_id(user_id) return new_error( ERROR_TYPES['missing_parameter'], "The resend_message method must be invoked with a non-empty string user_id argument." ) end if !self.is_valid_id() return new_error( ERROR_TYPES['missing_parameter'], "The resend_message method must be invoked with a non-empty string message_id argument." ) end path = "services/#{service_id}/users/#{user_id}/messages/#{}/resend" request = HttpRequest.new("POST", @base_url, path) @http_client.send(request) end |