Class: BaseCRM::TextMessagesService

Inherits:
Object
  • Object
show all
Defined in:
lib/basecrm/services/text_messages_service.rb

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ TextMessagesService

Returns a new instance of TextMessagesService.



5
6
7
# File 'lib/basecrm/services/text_messages_service.rb', line 5

def initialize(client)
  @client = client
end

Instance Method Details

#allEnumerable

Retrieve text messages

get ‘/text_messages’

If you want to use filtering or sorting (see #where).

Returns:

  • (Enumerable)

    Paginated resource you can use to iterate over all the resources.



15
16
17
# File 'lib/basecrm/services/text_messages_service.rb', line 15

def all
  PaginatedResource.new(self)
end

#find(id) ⇒ TextMessage

Retrieve a single text message

get ‘/text_messages/BaseCRM#id

Returns a single text message according to the unique ID provided If the specified user does not exist, this query returns an error

Parameters:

  • id (Integer)

    Unique identifier of a TextMessage

Returns:



49
50
51
52
53
# File 'lib/basecrm/services/text_messages_service.rb', line 49

def find(id)
  _, _, root = @client.get("/text_messages/#{id}")

  TextMessage.new(root[:data])
end

#where(options = {}) ⇒ Array<TextMessage>

Retrieve text messages

get ‘/text_messages’

Returns Text Messages, according to the parameters provided

Parameters:

  • options (Hash) (defaults to: {})

    Search options

Options Hash (options):

  • :page (Integer) — default: 1

    Page number to start from. Page numbering starts at 1, and omitting the ‘page` parameter will return the first page.

  • :per_page (Integer) — default: 25

    Number of records to return per page. The default limit is 25 and the maximum number that can be returned at one time is 100.

  • :ids (String)

    Comma-separated list of text message IDs to be returned in request.

  • :resource_id (Integer)

    Unique identifier of a resource the text message is attached to. Requires also resource_type to be specified.

  • :resource_type (String)

    Name of a resource type the text message is attached to. Requires also resource_id to be specified.

  • :sort_by (String) — default: id:desc

    Comma-separated list of fields to sort by. The sort criteria is applied in the order specified. The default ordering is descending. If you want to change the sort ordering to ascending, append ‘:asc` to the field e.g. `sort_by=id:asc`

Returns:

  • (Array<TextMessage>)

    The list of TextMessages for the first page, unless otherwise specified.



33
34
35
36
37
# File 'lib/basecrm/services/text_messages_service.rb', line 33

def where(options = {})
  _, _, root = @client.get("/text_messages", options)

  root[:items].map{ |item| TextMessage.new(item[:data]) }
end