Class: RSimpy::BaseService

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

Direct Known Subclasses

PostingService, QueryingService

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#status_codeObject (readonly)

Returns the value of attribute status_code.



3
4
5
# File 'lib/base_service.rb', line 3

def status_code
  @status_code
end

#status_messageObject (readonly)

Returns the value of attribute status_message.



3
4
5
# File 'lib/base_service.rb', line 3

def status_message
  @status_message
end

#successObject (readonly)

Returns the value of attribute success.



3
4
5
# File 'lib/base_service.rb', line 3

def success
  @success
end

Instance Method Details

#execute_using(method, params) ⇒ Object



19
20
21
22
23
24
25
26
# File 'lib/base_service.rb', line 19

def execute_using method, params
  reset

  response = @client.execute method, build_link(params)
  set_status response

  response
end

#resetObject



5
6
7
8
9
# File 'lib/base_service.rb', line 5

def reset
  @success = false
  @status_message = nil
  @status_code = nil
end

#set_status(response) ⇒ Object



11
12
13
14
15
16
17
# File 'lib/base_service.rb', line 11

def set_status response
  @success = ((response.code == 200) && response['status']['code'] == "0")
  if response.code == 200
    @status_code = response['status']['code']
    @status_message = response['status']['message']
  end
end