Class: Tender::Client

Inherits:
Object
  • Object
show all
Includes:
Discussion
Defined in:
lib/tender/client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Discussion

#create_discussion, #get_discussions

Constructor Details

#initialize(domain, api_token) ⇒ Client

Returns a new instance of Client.



8
9
10
11
# File 'lib/tender/client.rb', line 8

def initialize(domain, api_token)
  self.domain = domain # 'tender-api-testing'
  self.api_token = api_token # 'b19343da7748bd4e97d13fcc8b76304a039eb801'
end

Instance Attribute Details

#api_tokenObject

Returns the value of attribute api_token.



6
7
8
# File 'lib/tender/client.rb', line 6

def api_token
  @api_token
end

#domainObject

Returns the value of attribute domain.



6
7
8
# File 'lib/tender/client.rb', line 6

def domain
  @domain
end

#domain_formatObject

Returns the value of attribute domain_format.



6
7
8
# File 'lib/tender/client.rb', line 6

def domain_format
  @domain_format
end

#host_formatObject

Returns the value of attribute host_format.



6
7
8
# File 'lib/tender/client.rb', line 6

def host_format
  @host_format
end

#passwordObject

Returns the value of attribute password.



6
7
8
# File 'lib/tender/client.rb', line 6

def password
  @password
end

#portObject

Returns the value of attribute port.



6
7
8
# File 'lib/tender/client.rb', line 6

def port
  @port
end

#protocolObject

Returns the value of attribute protocol.



6
7
8
# File 'lib/tender/client.rb', line 6

def protocol
  @protocol
end

Instance Method Details

#connectionObject



13
14
15
16
17
18
19
20
21
22
# File 'lib/tender/client.rb', line 13

def connection
  @conn ||= Faraday.new(url: "https://api.tenderapp.com/#{self.domain}" ) do |faraday|
    faraday.use FaradayMiddleware::EncodeJson
    faraday.use FaradayMiddleware::ParseJson, :content_type => /\bjson$/
    faraday.adapter Faraday.default_adapter
  end
  @conn.headers['Accept'] = "application/vnd.tender-v1+json"
  @conn.headers['X-Tender-Auth'] = self.api_token
  @conn
end