Class: PortaText::Command::Api::ContactLists
- Defined in:
- lib/portatext/command/api/contact_lists.rb
Overview
The contact_lists endpoint. github.com/PortaText/docs/wiki/REST-API#api_contact_lists
- Author
-
Marcelo Gornstein ([email protected])
- Copyright
-
Copyright © 2015 PortaText
- License
-
Apache-2.0
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
- #csv(file) ⇒ Object
- #description(description) ⇒ Object
-
#endpoint(_method) ⇒ Object
rubocop:disable Metrics/MethodLength rubocop:disable Metrics/AbcSize.
- #id(id) ⇒ Object
- #name(name) ⇒ Object
- #page(page) ⇒ Object
- #save_to(file) ⇒ Object
- #with_number(number, variables = nil) ⇒ Object
Methods inherited from Base
#accept_content_type, #body, #content_type, #delete, #get, #initialize, #patch, #post, #put, #set
Constructor Details
This class inherits a constructor from PortaText::Command::Base
Instance Method Details
#csv(file) ⇒ Object
23 24 25 |
# File 'lib/portatext/command/api/contact_lists.rb', line 23 def csv(file) set :file, file end |
#description(description) ⇒ Object
19 20 21 |
# File 'lib/portatext/command/api/contact_lists.rb', line 19 def description(description) set :description, description end |
#endpoint(_method) ⇒ Object
rubocop:disable Metrics/MethodLength rubocop:disable Metrics/AbcSize
47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# 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) ⇒ Object
11 12 13 |
# File 'lib/portatext/command/api/contact_lists.rb', line 11 def id(id) set :id, id end |
#name(name) ⇒ Object
15 16 17 |
# File 'lib/portatext/command/api/contact_lists.rb', line 15 def name(name) set :name, name end |
#page(page) ⇒ Object
41 42 43 |
# File 'lib/portatext/command/api/contact_lists.rb', line 41 def page(page) set :page, page end |
#save_to(file) ⇒ Object
27 28 29 |
# File 'lib/portatext/command/api/contact_lists.rb', line 27 def save_to(file) set :accept_file, file end |
#with_number(number, variables = nil) ⇒ Object
31 32 33 34 35 36 37 38 39 |
# 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 |