Class: Bling::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/bling/config.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfig

Returns a new instance of Config.


4
5
6
7
# File 'lib/bling/config.rb', line 4

def initialize
  @api_url = 'https://bling.com.br/Api/v2/'
  @response_format = :json
end

Instance Attribute Details

#api_keyString

The api key supplied by Bling service.

Returns:

  • (String)

12
13
14
# File 'lib/bling/config.rb', line 12

def api_key
  @api_key
end

#api_urlString (readonly)

The base API url

Returns:

  • (String)

24
25
26
# File 'lib/bling/config.rb', line 24

def api_url
  @api_url
end

Instance Method Details

#default_languageSymbol

The default language of API params

Returns:

  • (Symbol)

45
46
47
# File 'lib/bling/config.rb', line 45

def default_language
  @default_language || :en
end

#default_language=(language) ⇒ Object

The default language if set to english lib will translate to portuguese before actually make request. Default to :en

Parameters:

  • (:pt, :en)

Raises:

  • (ArgumentError)

37
38
39
40
# File 'lib/bling/config.rb', line 37

def default_language=(language)
  raise ArgumentError unless [:en, :pt].include?(language.to_sym)
  @default_language = language.to_sym
end

#response_formatSymbol

The response format from Bling, can be :xml or :json (default).

Returns:

  • (Symbol)

29
30
31
# File 'lib/bling/config.rb', line 29

def response_format
  @response_format || :json
end

#response_format=(response_format) ⇒ Object

Set response format from Bling, can be :xml or :json (default).

Parameters:

  • (:xml, :json, 'xml', 'json')

17
18
19
# File 'lib/bling/config.rb', line 17

def response_format=(response_format)
  @response_format = response_format.to_sym
end