Class: Emvoicer::Services::Blinksale

Inherits:
HttpAuth show all
Extended by:
BlinksaleParsing
Defined in:
lib/emvoicer/services/blinksale.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from BlinksaleParsing

extract_client_node, extract_invoice_nodes, parse_client, parse_invoice

Methods inherited from HttpAuth

#authentication_valid?, #request_headers

Methods inherited from Base

#client, extract_client_node, extract_invoice_nodes, #generate_client, #generate_invoice, #handle_client_source, #handle_invoices_source, #invoices, parse_client, parse_invoice, #request, #request_headers

Constructor Details

#initialize(subdomain, username, password) ⇒ Blinksale

Returns a new instance of Blinksale.



10
11
12
13
14
# File 'lib/emvoicer/services/blinksale.rb', line 10

def initialize(subdomain, username, password)
  @subdomain = subdomain
  @username = username
  @password = password
end

Instance Attribute Details

#passwordObject (readonly)

Returns the value of attribute password.



8
9
10
# File 'lib/emvoicer/services/blinksale.rb', line 8

def password
  @password
end

#subdomainObject (readonly)

Returns the value of attribute subdomain.



8
9
10
# File 'lib/emvoicer/services/blinksale.rb', line 8

def subdomain
  @subdomain
end

#usernameObject (readonly)

Returns the value of attribute username.



8
9
10
# File 'lib/emvoicer/services/blinksale.rb', line 8

def username
  @username
end

Class Method Details

.test_authentication_response(response) ⇒ Object



39
40
41
42
43
44
45
# File 'lib/emvoicer/services/blinksale.rb', line 39

def self.test_authentication_response(response)
  case response
  when Net::HTTPSuccess then true
  else
    false
  end
end

Instance Method Details

#auth_paramsObject



16
17
18
# File 'lib/emvoicer/services/blinksale.rb', line 16

def auth_params
  [username, password]
end

#base_urlObject



27
28
29
# File 'lib/emvoicer/services/blinksale.rb', line 27

def base_url
  "https://#{ subdomain }.blinksale.com"
end

#client_url(id) ⇒ Object



35
36
37
# File 'lib/emvoicer/services/blinksale.rb', line 35

def client_url(id)
  base_url + "/clients/#{ id }"
end

#headersObject



20
21
22
23
24
25
# File 'lib/emvoicer/services/blinksale.rb', line 20

def headers
  {
    "Content-Type" => "application/vnd.blinksale+xml",
    "Accept" => "application/vnd.blinksale+xml"
  }
end

#invoices_urlObject



31
32
33
# File 'lib/emvoicer/services/blinksale.rb', line 31

def invoices_url
  base_url + "/invoices"
end