Class: Cetustek::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/cetustek/configuration.rb

Constant Summary collapse

TRANSPORTS =

HTTPI (savon 的預設) 第一順位是 httpclient,而 httpclient 只認 gem 內附的 cacert.pem,裡面沒有 Certum Trusted Root CA — 也就是 sandbox 端點 invoice.cetustek.com.tw 憑證鏈的根。只要環境裡有 httpclient,沙盒開票就會 全數 certificate verify failed。改用 :faraday 走 net_http,讀系統信任庫。

%i[httpi faraday].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



15
16
17
18
# File 'lib/cetustek/configuration.rb', line 15

def initialize
  @environment = :sandbox
  @transport = :httpi
end

Instance Attribute Details

#environmentObject

logger is opt-in: nil means this gem writes nothing anywhere.



12
13
14
# File 'lib/cetustek/configuration.rb', line 12

def environment
  @environment
end

#loggerObject

logger is opt-in: nil means this gem writes nothing anywhere.



12
13
14
# File 'lib/cetustek/configuration.rb', line 12

def logger
  @logger
end

#passwordObject

logger is opt-in: nil means this gem writes nothing anywhere.



12
13
14
# File 'lib/cetustek/configuration.rb', line 12

def password
  @password
end

#site_idObject

logger is opt-in: nil means this gem writes nothing anywhere.



12
13
14
# File 'lib/cetustek/configuration.rb', line 12

def site_id
  @site_id
end

#transportObject

Returns the value of attribute transport.



13
14
15
# File 'lib/cetustek/configuration.rb', line 13

def transport
  @transport
end

#usernameObject

logger is opt-in: nil means this gem writes nothing anywhere.



12
13
14
# File 'lib/cetustek/configuration.rb', line 12

def username
  @username
end

Instance Method Details

#production?Boolean

Returns:

  • (Boolean)


35
36
37
# File 'lib/cetustek/configuration.rb', line 35

def production?
  @environment == :production
end

#sandbox?Boolean

Returns:

  • (Boolean)


39
40
41
# File 'lib/cetustek/configuration.rb', line 39

def sandbox?
  @environment == :sandbox
end

#urlObject



27
28
29
30
31
32
33
# File 'lib/cetustek/configuration.rb', line 27

def url
  if @environment == :production
    'https://www.ei.com.tw/InvoiceMultiWeb/InvoiceAPI?wsdl'
  else
    'https://invoice.cetustek.com.tw/InvoiceMultiWeb/InvoiceAPI?wsdl'
  end
end