Sha256: 4c98428e20fbe02a62de67b1f6d5b6a39e1086102701b99b616dae142ccb5760
Contents?: true
Size: 1.97 KB
Versions: 34
Compression:
Stored size: 1.97 KB
Contents
module PortaText module Command module Api # The contacts endpoint. # https://github.com/PortaText/docs/wiki/REST-API#api_all_contacts # # Author:: Marcelo Gornstein (mailto:marcelog@portatext.com) # Copyright:: Copyright (c) 2015 PortaText # License:: Apache-2.0 class Contacts < Base def id(number) set :number, number end def with_contact_lists set :with_contact_lists, true end def page(page) set :page, page end def name(name) set :name, name end def set_to(name, value) self.name name set :value, value end def csv(file) set :file, file end def save_to(file) set :accept_file, file end # rubocop:disable Style/AccessorMethodName def set_all(variables) variables = variables.reduce([]) do |acc, v| acc << { key: v[0], value: v[1] } end set :variables, variables end # rubocop:enable Style/AccessorMethodName # rubocop:disable Metrics/MethodLength # rubocop:disable Metrics/AbcSize def endpoint(_method) qs = {} unless @args[:page].nil? qs['page'] = @args[:page] @args.delete :page end unless @args[:with_contact_lists].nil? qs['with_contact_lists'] = 'true' @args.delete :with_contact_lists end qs = URI.encode_www_form qs return "contacts?#{qs}" if @args[:number].nil? number = @args[:number] @args.delete :number return "contacts/#{number}/variables" if @args[:name].nil? name = @args[:name] @args.delete :name "contacts/#{number}/variables/#{name}" end # rubocop:enable Metrics/MethodLength # rubocop:enable Metrics/AbcSize end end end end
Version data entries
34 entries across 34 versions & 1 rubygems