Class: ABBYY::Cloud::Operations::Base

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/abbyy/cloud/operations/base.rb

Direct Known Subclasses

Engines, Prices, Translate, TranslateSegments

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.http_method(value = nil) ⇒ Object



13
14
15
16
# File 'lib/abbyy/cloud/operations/base.rb', line 13

def http_method(value = nil)
  @http_method = value.to_s.capitalize if value
  @http_method || "Post"
end


22
23
24
# File 'lib/abbyy/cloud/operations/base.rb', line 22

def link(value = nil)
  value ? @link = value : @link
end

.path(value = nil) ⇒ Object



18
19
20
# File 'lib/abbyy/cloud/operations/base.rb', line 18

def path(value = nil)
  value ? @path = value : @path
end

.request_body(struct = nil, &block) ⇒ Object



26
27
28
# File 'lib/abbyy/cloud/operations/base.rb', line 26

def request_body(struct = nil, &block)
  provide_struct :@request_body, struct, &block
end

.request_query(struct = nil, &block) ⇒ Object



30
31
32
# File 'lib/abbyy/cloud/operations/base.rb', line 30

def request_query(struct = nil, &block)
  provide_struct :@request_query, struct, &block
end

.response_body(struct = nil, &block) ⇒ Object



34
35
36
# File 'lib/abbyy/cloud/operations/base.rb', line 34

def response_body(struct = nil, &block)
  provide_struct :@response_body, struct, &block
end

Instance Method Details

#call(**data) ⇒ Object



64
65
66
67
68
69
70
# File 'lib/abbyy/cloud/operations/base.rb', line 64

def call(**data)
  body  = prepare_request_body(data)
  query = prepare_request_query(data)
  res   = connection.call(http_method, path, body: body, query: query)

  handle_response_body(res)
end