Module: RGData::API::ClassMethods

Defined in:
lib/rgdata/api.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#modelObject

Returns the value of attribute model.



15
16
17
# File 'lib/rgdata/api.rb', line 15

def model
  @model
end

#scopeObject

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 and return response. options can be :oauth_token, :access_token, or :refresh_token.



23
24
25
26
27
28
# File 'lib/rgdata/api.rb', line 23

def do_request(domain, options)
  oauth_token = extract_oauth_token_or_access_token_or_get_one_using_refresh_token(options)
  query = {oauth_token: oauth_token}
  query.verify_keys_present_and_values_not_nil(:oauth_token)
  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 instantiate new model objects.



31
32
33
34
35
36
# File 'lib/rgdata/api.rb', line 31

def retrieve(domain, options)
  full_xml_hash = do_request(domain, options)
  full_xml_hash['feed']['entry'].map do |xml_hash|
    model.new_from_xml_hash xml_hash
  end
end