Class: PortaText::Command::Api::Simulate
- Defined in:
- lib/portatext/command/api/simulate.rb
Overview
The simulate endpoint. github.com/PortaText/docs/wiki/REST-API#api_simulate
- Author
-
Marcelo Gornstein ([email protected])
- Copyright
-
Copyright © 2015 PortaText
- License
-
Apache-2.0
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
- #country(country) ⇒ Object
-
#endpoint(_method) ⇒ Object
rubocop:disable Metrics/MethodLength rubocop:disable Metrics/AbcSize.
- #text(text) ⇒ Object
- #use_template(id, variables = {}) ⇒ 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
#country(country) ⇒ Object
11 12 13 |
# File 'lib/portatext/command/api/simulate.rb', line 11 def country(country) set :country, country end |
#endpoint(_method) ⇒ Object
rubocop:disable Metrics/MethodLength rubocop:disable Metrics/AbcSize
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# 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) ⇒ Object
20 21 22 |
# File 'lib/portatext/command/api/simulate.rb', line 20 def text(text) set :text, text end |
#use_template(id, variables = {}) ⇒ Object
15 16 17 18 |
# File 'lib/portatext/command/api/simulate.rb', line 15 def use_template(id, variables = {}) set :template_id, id set :variables, variables end |