Module: RGData::API::ClassMethods
- Defined in:
- lib/rgdata/api.rb
Instance Attribute Summary collapse
-
#model ⇒ Object
Returns the value of attribute model.
-
#scope ⇒ Object
Returns the value of attribute scope.
Instance Method Summary collapse
-
#do_request(domain, options) ⇒ Object
Send request for data (not authentication) and return response.
- #request_url(redirect_uri) ⇒ Object
-
#retrieve(domain, options) ⇒ Object
Perform request and create new model objects.
Instance Attribute Details
#model ⇒ Object
Returns the value of attribute model.
15 16 17 |
# File 'lib/rgdata/api.rb', line 15 def model @model end |
#scope ⇒ Object
Returns the value of attribute scope.
14 15 16 |
# File 'lib/rgdata/api.rb', line 14 def scope @scope end |
Instance Method Details
#do_request(domain, options) ⇒ Object
Send request for data (not authentication) and return response. options can be :oauth_token, :access_token, or :refresh_token.
23 24 25 26 27 28 29 30 31 |
# File 'lib/rgdata/api.rb', line 23 def do_request(domain, ) oauth_token = extract_oauth_token_or_access_token_or_get_one_using_refresh_token() query = { oauth_token: oauth_token, } query.verify_keys_present_and_values_not_blank(:oauth_token) raise 'Domain cannot be blank' if domain.blank? get "/#{domain}/full", query: query end |
#request_url(redirect_uri) ⇒ Object
17 18 19 |
# File 'lib/rgdata/api.rb', line 17 def request_url(redirect_uri) RGData::Authentication.request_url(scope, redirect_uri) end |
#retrieve(domain, options) ⇒ Object
Perform request and create new model objects. See do_request() for arguments info.
35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/rgdata/api.rb', line 35 def retrieve(domain, ) raise 'domain cannot be nil' unless domain full_xml_hash = do_request(domain, ) full_xml_hash['feed']['entry'].map do |xml_hash| model.new_from_xml_hash xml_hash end rescue puts 'Unexpected response:' puts full_xml_hash raise end |