Class: VerticalResponse::API::Message
- Defined in:
- lib/message.rb
Instance Attribute Summary
Attributes inherited from Client
Class Method Summary collapse
-
.base_uri(*args) ⇒ Object
Base URI for the Message resource.
-
.object_collection(response) ⇒ Object
Overwritting this method from the parent class since we want to return object instances depending on the message type.
Methods inherited from Resource
all, class_for_resource, class_name, create, #delete, exclude_methods, find, #id, id_attribute_name, id_regexp, resource_id_from_url, resource_name, #stats, #update, #url, validate_supported_method!
Methods inherited from Client
add_default_query_param, assign_headers, build_params, build_query_params, config, default_query_params, embed_resource, #initialize, resource_uri
Constructor Details
This class inherits a constructor from VerticalResponse::API::Client
Class Method Details
.base_uri(*args) ⇒ Object
Base URI for the Message resource
17 18 19 |
# File 'lib/message.rb', line 17 def base_uri(*args) @base_uri ||= File.join(super.to_s, 'messages') end |
.object_collection(response) ⇒ Object
Overwritting this method from the parent class since we want to return object instances depending on the message type
23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/message.rb', line 23 def object_collection(response) response.handle_collection do |response_item| = self if response_item.attributes && response_item.attributes.has_key?('message_type') type = response_item.attributes['message_type'].downcase.gsub(' ', '_') if type == Email::MESSAGE_TYPE = Email elsif type == SocialPost::MESSAGE_TYPE = SocialPost end end .new(response_item) end end |