class PortaText::Command::Api::Simulate

The simulate endpoint. github.com/PortaText/docs/wiki/REST-API#api_simulate

Author

Marcelo Gornstein (marcelog@portatext.com)

Copyright

Copyright © 2015 PortaText

License

Apache-2.0

Public Instance Methods

country(country) click to toggle source
# File lib/portatext/command/api/simulate.rb, line 11
def country(country)
  set :country, country
end
endpoint(_method) click to toggle source

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

# File lib/portatext/command/api/simulate.rb, line 26
def endpoint(_method)
  raise 'Country cant be null' if @args[:country].nil?
  qs = { 'country' => @args.delete(:country) }
  @args.delete :country
  unless @args[:text].nil?
    qs['text'] = @args[:text]
    @args.delete :text
  end
  unless @args[:template_id].nil?
    qs['template_id'] = @args[:template_id]
    @args.delete :template_id
  end
  unless @args[:variables].nil?
    qs['variables'] = @args[:variables].to_json
    @args.delete :variables
  end
  "simulate?#{URI.encode_www_form qs}"
end
text(text) click to toggle source
# File lib/portatext/command/api/simulate.rb, line 20
def text(text)
  set :text, text
end
use_template(id, variables = {}) click to toggle source
# File lib/portatext/command/api/simulate.rb, line 15
def use_template(id, variables = {})
  set :template_id, id
  set :variables, variables
end