Class: Buezli::Api::Client
- Inherits:
-
Object
- Object
- Buezli::Api::Client
- Defined in:
- lib/buezli/api/client.rb,
lib/buezli/api/client/list.rb,
lib/buezli/api/client/error.rb,
lib/buezli/api/client/record.rb,
lib/buezli/api/client/download.rb
Defined Under Namespace
Classes: Download, Error, List, Record
Constant Summary collapse
- DEFAULT_ENDPOINT =
"https://api.buezli.app"
Instance Attribute Summary collapse
-
#access_token ⇒ Object
readonly
Returns the value of attribute access_token.
-
#endpoint ⇒ Object
readonly
Returns the value of attribute endpoint.
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#schema ⇒ Object
readonly
Returns the value of attribute schema.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Instance Method Summary collapse
- #build_record(model_name, attributes) ⇒ Object
-
#initialize(access_token:, endpoint: DEFAULT_ENDPOINT, version: nil, schema: nil, host: nil) ⇒ Client
constructor
A new instance of Client.
- #inspect ⇒ Object
Constructor Details
#initialize(access_token:, endpoint: DEFAULT_ENDPOINT, version: nil, schema: nil, host: nil) ⇒ Client
Returns a new instance of Client.
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/buezli/api/client.rb', line 8 def initialize(access_token:, endpoint: DEFAULT_ENDPOINT, version: nil, schema: nil, host: nil) @access_token = access_token @endpoint = endpoint.chomp("/") @schema = schema || load_schema(version) @version = version || @schema.version @host = host raise ArgumentError, "Schema version does not match requested version" if @schema.version != @version define_methods_from_schema end |
Instance Attribute Details
#access_token ⇒ Object (readonly)
Returns the value of attribute access_token.
6 7 8 |
# File 'lib/buezli/api/client.rb', line 6 def access_token @access_token end |
#endpoint ⇒ Object (readonly)
Returns the value of attribute endpoint.
6 7 8 |
# File 'lib/buezli/api/client.rb', line 6 def endpoint @endpoint end |
#host ⇒ Object (readonly)
Returns the value of attribute host.
6 7 8 |
# File 'lib/buezli/api/client.rb', line 6 def host @host end |
#schema ⇒ Object (readonly)
Returns the value of attribute schema.
6 7 8 |
# File 'lib/buezli/api/client.rb', line 6 def schema @schema end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
6 7 8 |
# File 'lib/buezli/api/client.rb', line 6 def version @version end |
Instance Method Details
#build_record(model_name, attributes) ⇒ Object
19 20 21 |
# File 'lib/buezli/api/client.rb', line 19 def build_record(model_name, attributes) Record.new(attributes:, model_name:, api_client: self, schema:) end |
#inspect ⇒ Object
23 24 25 |
# File 'lib/buezli/api/client.rb', line 23 def inspect "#<#{self.class.name} endpoint=#{endpoint.inspect} version=#{version.inspect} host=#{host.inspect}>" end |