Sha256: 18a67c48c0720f4460a1ce1efb118f1851717061d375287ba21b2bdc5383b08a

Contents?: true

Size: 1.38 KB

Versions: 16

Compression:

Stored size: 1.38 KB

Contents

module PortaText
  module Command
    module Api
      # The sms endpoint.
      # https://github.com/PortaText/docs/wiki/REST-API#api_sms
      #
      # Author::    Marcelo Gornstein (mailto:marcelog@portatext.com)
      # Copyright:: Copyright (c) 2015 PortaText
      # License::   Apache-2.0
      class Sms < Base
        def id(id)
          set :id, id
        end

        def to(to)
          set :to, to
        end

        def from(from)
          set :from, from
        end

        def from_service(service_id)
          set :service_id, service_id
        end

        def use_template(id, variables = {})
          set :template_id, id
          set :variables, variables
        end

        def text(text)
          set :text, text
        end

        def client_ref(client_ref)
          set :client_ref, client_ref
        end

        def to_contact_lists(contact_lists)
          set :contact_list_ids, contact_lists
        end

        def search(params)
          set :search_params, params
        end

        def endpoint(_method)
          unless @args[:search_params].nil?
            qs = URI.encode_www_form @args[:search_params]
            @args.delete :search_params
            return "sms?#{qs}"
          end

          return 'sms' if @args[:id].nil?
          id = @args[:id]
          @args.delete :id
          "sms/#{id}"
        end
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
portatext-1.5.13 lib/portatext/command/api/sms.rb
portatext-1.5.12 lib/portatext/command/api/sms.rb
portatext-1.5.11 lib/portatext/command/api/sms.rb
portatext-1.5.10 lib/portatext/command/api/sms.rb
portatext-1.5.9 lib/portatext/command/api/sms.rb
portatext-1.5.8 lib/portatext/command/api/sms.rb
portatext-1.5.7 lib/portatext/command/api/sms.rb
portatext-1.5.6 lib/portatext/command/api/sms.rb
portatext-1.5.5 lib/portatext/command/api/sms.rb
portatext-1.5.4 lib/portatext/command/api/sms.rb
portatext-1.5.3 lib/portatext/command/api/sms.rb
portatext-1.5.2 lib/portatext/command/api/sms.rb
portatext-1.5.1 lib/portatext/command/api/sms.rb
portatext-1.5.0 lib/portatext/command/api/sms.rb
portatext-1.4.4 lib/portatext/command/api/sms.rb
portatext-1.4.3 lib/portatext/command/api/sms.rb