Class: Awis::API::Base
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
camelize
Instance Attribute Details
#arguments ⇒ Object
Returns the value of attribute arguments.
7
8
9
|
# File 'lib/awis/api/base.rb', line 7
def arguments
@arguments
end
|
#response_body ⇒ Object
Returns the value of attribute response_body.
7
8
9
|
# File 'lib/awis/api/base.rb', line 7
def response_body
@response_body
end
|
Class Method Details
.loading_data_from_xml(xml_file_path) ⇒ Object
48
49
50
|
# File 'lib/awis/api/base.rb', line 48
def loading_data_from_xml(xml_file_path)
MultiXml.parse(File.new(xml_file_path))
end
|
Instance Method Details
#action_name ⇒ Object
32
33
34
|
# File 'lib/awis/api/base.rb', line 32
def action_name
self.class.name.split(/\:\:/)[-1]
end
|
#before_validation_arguments(arguments) ⇒ Object
42
43
44
45
|
# File 'lib/awis/api/base.rb', line 42
def before_validation_arguments(arguments)
raise ArgumentError, "Invalid arguments. should be like { url: 'site.com' }" unless arguments.is_a?(Hash)
raise ArgumentError, 'Invalid arguments. the url must be configured.' unless arguments.key?(:url)
end
|
#fetch(arguments = {}) ⇒ Object
9
10
11
12
13
14
|
# File 'lib/awis/api/base.rb', line 9
def fetch(arguments = {})
validation_arguments!(arguments)
loading_response_body
self
end
|
#load_request_uri(params) ⇒ Object
36
37
38
39
40
|
# File 'lib/awis/api/base.rb', line 36
def load_request_uri(params)
collection = Awis::Connection.new
collection.setup_params(params)
collection.uri
end
|
#loading_response_body ⇒ Object
24
25
26
|
# File 'lib/awis/api/base.rb', line 24
def loading_response_body
@response_body = Awis::Connection.new.get(params)
end
|
#parsed_body ⇒ Object
20
21
22
|
# File 'lib/awis/api/base.rb', line 20
def parsed_body
@parsed_body ||= MultiXml.parse(response_body)
end
|
#request_description_params ⇒ Object
16
17
18
|
# File 'lib/awis/api/base.rb', line 16
def request_description_params
arguments[:descriptions].to_s.capitalize
end
|
#root_node_name ⇒ Object
28
29
30
|
# File 'lib/awis/api/base.rb', line 28
def root_node_name
"#{action_name}Response"
end
|