Class: Yapi::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/yapi/client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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_keyObject

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(options = {})
  url = ""
  options.each do |key, value|
    url << "&" << key.id2name << "=" << value
  end
  return URI.escape(url)
end

#get_api_keyObject



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