Class: Yapi::Client
- Inherits:
-
Object
- Object
- Yapi::Client
- Defined in:
- lib/yapi/client.rb
Instance Attribute Summary collapse
-
#api_key ⇒ Object
Returns the value of attribute api_key.
Instance Method Summary collapse
- #build_url(options = {}) ⇒ Object
- #get_api_key ⇒ Object
-
#initialize(api_key) ⇒ Client
constructor
A new instance of Client.
- #xml_to_json(xml) ⇒ Object
Constructor Details
#initialize(api_key) ⇒ Client
Returns a new instance of Client.
10 11 12 |
# File 'lib/yapi/client.rb', line 10 def initialize(api_key) self.api_key = api_key end |
Instance Attribute Details
#api_key ⇒ Object
Returns the value of attribute api_key.
8 9 10 |
# File 'lib/yapi/client.rb', line 8 def api_key @api_key end |
Instance Method Details
#build_url(options = {}) ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/yapi/client.rb', line 18 def build_url( = {}) url = "" .each do |key, value| url << "&" << key.id2name << "=" << value end return URI.escape(url) end |
#get_api_key ⇒ Object
14 15 16 |
# File 'lib/yapi/client.rb', line 14 def get_api_key return self.api_key end |
#xml_to_json(xml) ⇒ Object
26 27 28 29 |
# File 'lib/yapi/client.rb', line 26 def xml_to_json xml doc = Hash.from_xml xml return JSON.parse(doc.to_json, symbolize_names: true) end |