Class: SevenApi::Resource

Inherits:
Object
  • Object
show all
Defined in:
lib/seven_api/resource.rb

Constant Summary collapse

BASE_PATH =
'/api/'

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_key, sent_with = 'ruby') ⇒ Resource

Returns a new instance of Resource.



15
16
17
18
19
20
21
22
23
24
# File 'lib/seven_api/resource.rb', line 15

def initialize(api_key, sent_with = 'ruby')
  raise 'missing api_key in config' if api_key.to_s.empty?
  raise 'missing sent_with in config' if sent_with.to_s.empty?

  @api_key = api_key
  @sent_with = sent_with
  @endpoint = self.class.get_endpoint
  @http_methods = self.class.get_http_methods
  @conn = Faraday.new("https://gateway.seven.io#{BASE_PATH}")
end

Instance Attribute Details

#api_keyObject (readonly)

Returns the value of attribute api_key.



11
12
13
# File 'lib/seven_api/resource.rb', line 11

def api_key
  @api_key
end

#builderObject (readonly)

Returns the value of attribute builder.



11
12
13
# File 'lib/seven_api/resource.rb', line 11

def builder
  @builder
end

#connObject (readonly)

Returns the value of attribute conn.



11
12
13
# File 'lib/seven_api/resource.rb', line 11

def conn
  @conn
end

#endpointObject (readonly)

Returns the value of attribute endpoint.



11
12
13
# File 'lib/seven_api/resource.rb', line 11

def endpoint
  @endpoint
end

#http_methodsObject (readonly)

Returns the value of attribute http_methods.



11
12
13
# File 'lib/seven_api/resource.rb', line 11

def http_methods
  @http_methods
end

#request_methodsObject (readonly)

Returns the value of attribute request_methods.



11
12
13
# File 'lib/seven_api/resource.rb', line 11

def request_methods
  @request_methods
end

#sent_withObject (readonly)

Returns the value of attribute sent_with.



11
12
13
# File 'lib/seven_api/resource.rb', line 11

def sent_with
  @sent_with
end

Class Method Details

.get_endpointObject



94
95
96
# File 'lib/seven_api/resource.rb', line 94

def get_endpoint
  @endpoint
end

.get_http_methodsObject



90
91
92
# File 'lib/seven_api/resource.rb', line 90

def get_http_methods
  @http_methods
end