Class: Asaas::Api::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/asaas/api/base.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client_token, api_version, route = nil) ⇒ Base

Returns a new instance of Base.



12
13
14
15
16
17
# File 'lib/asaas/api/base.rb', line 12

def initialize(client_token, api_version, route = nil)
  @token    = client_token
  @route    = route
  @api_version = api_version || Asaas::Configuration.api_version
  @endpoint = Asaas::Configuration.get_endpoint(api_version)
end

Instance Attribute Details

#endpointObject (readonly)

Returns the value of attribute endpoint.



5
6
7
# File 'lib/asaas/api/base.rb', line 5

def endpoint
  @endpoint
end

#errorsObject (readonly)

Returns the value of attribute errors.



7
8
9
# File 'lib/asaas/api/base.rb', line 7

def errors
  @errors
end

#metaObject (readonly)

Returns the value of attribute meta.



6
7
8
# File 'lib/asaas/api/base.rb', line 6

def meta
  @meta
end

#routeObject

Returns the value of attribute route.



10
11
12
# File 'lib/asaas/api/base.rb', line 10

def route
  @route
end

#successObject (readonly)

Returns the value of attribute success.



8
9
10
# File 'lib/asaas/api/base.rb', line 8

def success
  @success
end

#tokenObject (readonly)

Returns the value of attribute token.



9
10
11
# File 'lib/asaas/api/base.rb', line 9

def token
  @token
end

Instance Method Details

#create(attrs) ⇒ Object



33
34
35
36
# File 'lib/asaas/api/base.rb', line 33

def create(attrs)
  request(:post, {}, attrs)
  parse_response
end

#delete(id) ⇒ Object



43
44
45
46
# File 'lib/asaas/api/base.rb', line 43

def delete(id)
  request(:delete, {id: id})
  parse_response
end

#extract_meta(meta) ⇒ Object



19
20
21
# File 'lib/asaas/api/base.rb', line 19

def extract_meta(meta)
  @meta = Asaas::Entity::Meta.new(meta)
end

#get(id) ⇒ Object



23
24
25
26
# File 'lib/asaas/api/base.rb', line 23

def get(id)
  request(:get, {id: id})
  parse_response
end

#list(params = {}) ⇒ Object



28
29
30
31
# File 'lib/asaas/api/base.rb', line 28

def list(params = {})
  request(:get, params)
  parse_response
end

#update(attrs) ⇒ Object



38
39
40
41
# File 'lib/asaas/api/base.rb', line 38

def update(attrs)
  request(:post, {id: attrs.id}, attrs)
  parse_response
end