class PortaText::Command::Api::ContactLists

The contact_lists endpoint. github.com/PortaText/docs/wiki/REST-API#api_contact_lists

Author

Marcelo Gornstein (marcelog@portatext.com)

Copyright

Copyright © 2015 PortaText

License

Apache-2.0

Public Instance Methods

csv(file) click to toggle source
# File lib/portatext/command/api/contact_lists.rb, line 23
def csv(file)
  set :file, file
end
description(description) click to toggle source
# File lib/portatext/command/api/contact_lists.rb, line 19
def description(description)
  set :description, description
end
endpoint(_method) click to toggle source

rubocop:disable Metrics/MethodLength rubocop:disable Metrics/AbcSize

# File lib/portatext/command/api/contact_lists.rb, line 47
def endpoint(_method)
  return 'contact_lists' if @args[:id].nil?
  id = @args[:id]
  @args.delete :id
  number = @args[:number]
  @args.delete :number
  page = @args[:page]
  @args.delete :page
  return "contact_lists/#{id}/contacts/#{number}" unless number.nil?
  return "contact_lists/#{id}/contacts" unless @args[:file].nil?
  return "contact_lists/#{id}/contacts" unless @args[:accept_file].nil?
  return "contact_lists/#{id}/contacts?page=#{page}" unless page.nil?
  "contact_lists/#{id}"
end
id(id) click to toggle source
# File lib/portatext/command/api/contact_lists.rb, line 11
def id(id)
  set :id, id
end
name(name) click to toggle source
# File lib/portatext/command/api/contact_lists.rb, line 15
def name(name)
  set :name, name
end
page(page) click to toggle source
# File lib/portatext/command/api/contact_lists.rb, line 41
def page(page)
  set :page, page
end
save_to(file) click to toggle source
# File lib/portatext/command/api/contact_lists.rb, line 27
def save_to(file)
  set :accept_file, file
end
with_number(number, variables = nil) click to toggle source
# File lib/portatext/command/api/contact_lists.rb, line 31
def with_number(number, variables = nil)
  unless variables.nil?
    variables = variables.reduce([]) do |acc, v|
      acc << { key: v[0], value: v[1] }
    end
    set :variables, variables
  end
  set :number, number
end