Class: RUBG::RubgEndpoint
- Inherits:
-
Object
- Object
- RUBG::RubgEndpoint
- Defined in:
- lib/rubg/rubg_endpoint.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
-
#ratelimit ⇒ Object
readonly
Returns the value of attribute ratelimit.
-
#ratelimit_remaining ⇒ Object
readonly
Returns the value of attribute ratelimit_remaining.
-
#raw_response ⇒ Object
readonly
Returns the value of attribute raw_response.
-
#response_ts ⇒ Object
readonly
Returns the value of attribute response_ts.
Class Method Summary collapse
-
.fetch(args) ⇒ Object
client,endpoint,shard={},query_params={}.
Instance Method Summary collapse
-
#initialize(args) ⇒ RubgEndpoint
constructor
A new instance of RubgEndpoint.
Constructor Details
#initialize(args) ⇒ RubgEndpoint
Returns a new instance of RubgEndpoint.
5 6 7 8 9 10 11 12 13 |
# File 'lib/rubg/rubg_endpoint.rb', line 5 def initialize( args ) args = self.class.defaults.merge(args) @errors = args[:response]["errors"] @data = args[:response]["data"] @response_ts = Time.parse(args[:response].headers['date']) if args[:response].headers['date'] @ratelimit = args[:response].headers['x-ratelimit-limit'] @ratelimit_remaining = args[:response].headers['x-ratelimit-remaining'] @raw_response = args[:response] end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
3 4 5 |
# File 'lib/rubg/rubg_endpoint.rb', line 3 def data @data end |
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
3 4 5 |
# File 'lib/rubg/rubg_endpoint.rb', line 3 def errors @errors end |
#ratelimit ⇒ Object (readonly)
Returns the value of attribute ratelimit.
3 4 5 |
# File 'lib/rubg/rubg_endpoint.rb', line 3 def ratelimit @ratelimit end |
#ratelimit_remaining ⇒ Object (readonly)
Returns the value of attribute ratelimit_remaining.
3 4 5 |
# File 'lib/rubg/rubg_endpoint.rb', line 3 def ratelimit_remaining @ratelimit_remaining end |
#raw_response ⇒ Object (readonly)
Returns the value of attribute raw_response.
3 4 5 |
# File 'lib/rubg/rubg_endpoint.rb', line 3 def raw_response @raw_response end |
#response_ts ⇒ Object (readonly)
Returns the value of attribute response_ts.
3 4 5 |
# File 'lib/rubg/rubg_endpoint.rb', line 3 def response_ts @response_ts end |
Class Method Details
.fetch(args) ⇒ Object
client,endpoint,shard={},query_params={}
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/rubg/rubg_endpoint.rb', line 16 def self.fetch( args ) #client,endpoint,shard={},query_params={} args = self.defaults.merge(args) uri = assemble_uri({ :shard => args[:shard], :endpoint => args[:endpoint], :lookup_id => args[:lookup_id] }) headers = assemble_headers({ :client => args[:client] }) query = assemble_query({ :client => args[:client], :query_params => args[:query_params] }) @response = args[:client].class.get(uri,{headers: headers, query: query}) return @response end |