Class: Imagga::Categorization::Client
- Inherits:
-
Object
- Object
- Imagga::Categorization::Client
- Includes:
- HTTParty
- Defined in:
- lib/imagga/categorization/client.rb
Instance Method Summary collapse
- #classify(classifier_id, options = {}) ⇒ Object
- #classify_result(ticket_id) ⇒ Object
-
#initialize(options = {}) ⇒ Client
constructor
A new instance of Client.
- #task_result(task_id) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Client
Returns a new instance of Client.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/imagga/categorization/client.rb', line 11 def initialize(={}) # Merge the config values from the module and those passed # to the client. = Categorization..merge() # Copy the merged values to this client and ignore those # not part of our configuration Configuration::VALID_CONFIG_KEYS.each do |key| send("#{key}=", [key]) end # set the endpoint for HTTParty self.class.base_uri self.endpoint.to_s # set a default api_key parameter for each HTTParty request @options = { query: { api_key: self.api_key } } end |
Instance Method Details
#classify(classifier_id, options = {}) ⇒ Object
31 32 33 34 35 36 |
# File 'lib/imagga/categorization/client.rb', line 31 def classify(classifier_id, ={}) = { async: 1 } .merge!() = @options.merge({ body: .to_query }) self.class.post "/draft/classify/#{classifier_id}", end |
#classify_result(ticket_id) ⇒ Object
38 39 40 |
# File 'lib/imagga/categorization/client.rb', line 38 def classify_result(ticket_id) self.class.get "/draft/classify/result/#{ticket_id}", @options end |
#task_result(task_id) ⇒ Object
42 43 44 |
# File 'lib/imagga/categorization/client.rb', line 42 def task_result(task_id) self.class.get "/draft/tasks/#{task_id}", @options end |