Class: Erede::Environment

Inherits:
Object
  • Object
show all
Defined in:
lib/erede/environment.rb

Constant Summary collapse

PRODUCTION =
'https://api.userede.com.br/erede'
SANDBOX =
'https://api.userede.com.br/desenvolvedores'
API_VERSION =
'v1'

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(endpoint) ⇒ Environment

Returns a new instance of Environment.



11
12
13
# File 'lib/erede/environment.rb', line 11

def initialize(endpoint)
  @endpoint = "#{endpoint}/#{API_VERSION}"
end

Instance Attribute Details

#endpointObject

Returns the value of attribute endpoint.



7
8
9
# File 'lib/erede/environment.rb', line 7

def endpoint
  @endpoint
end

#ipObject

Returns the value of attribute ip.



7
8
9
# File 'lib/erede/environment.rb', line 7

def ip
  @ip
end

#session_idObject

Returns the value of attribute session_id.



7
8
9
# File 'lib/erede/environment.rb', line 7

def session_id
  @session_id
end

Class Method Details

.productionObject



15
16
17
# File 'lib/erede/environment.rb', line 15

def self.production
  new(PRODUCTION)
end

.sandboxObject



19
20
21
# File 'lib/erede/environment.rb', line 19

def self.sandbox
  new(SANDBOX)
end

Instance Method Details

#to_jsonObject



23
24
25
26
27
28
29
30
# File 'lib/erede/environment.rb', line 23

def to_json(*)
  {
    consumer: {
      ip: @ip,
      sessionId: @sessionId
    }
  }.delete_if { |k, v| v.nil? }.to_json
end