Class: Crefo::Service

Inherits:
Object
  • Object
show all
Defined in:
lib/crefo/service.rb,
lib/crefo/service/logon.rb,
lib/crefo/service/report.rb,
lib/crefo/service/search.rb,
lib/crefo/service/keylist.rb,
lib/crefo/service/request.rb,
lib/crefo/service/response.rb,
lib/crefo/service/logon/request.rb,
lib/crefo/service/logon/response.rb,
lib/crefo/service/report/request.rb,
lib/crefo/service/search/request.rb,
lib/crefo/service/change_password.rb,
lib/crefo/service/keylist/request.rb,
lib/crefo/service/report/response.rb,
lib/crefo/service/search/response.rb,
lib/crefo/service/keylist/response.rb,
lib/crefo/service/change_password/request.rb,
lib/crefo/service/change_password/response.rb

Direct Known Subclasses

ChangePassword, Keylist, Logon, Report, Search

Defined Under Namespace

Classes: ChangePassword, Keylist, Logon, Report, Request, Response, Result, Search

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Service

Returns a new instance of Service.



8
9
10
# File 'lib/crefo/service.rb', line 8

def initialize(options = {})
  @options = options
end

Instance Attribute Details

#logObject (readonly)

Returns the value of attribute log.



6
7
8
# File 'lib/crefo/service.rb', line 6

def log
  @log
end

#optionsObject (readonly)

Returns the value of attribute options.



6
7
8
# File 'lib/crefo/service.rb', line 6

def options
  @options
end

Instance Method Details

#processObject



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/crefo/service.rb', line 12

def process
  begin
    url = Crefo.config.endpoint
    request = self.class::Request.new(**options)
    response_data = request.send(url)
    response = self.class::Response.new(response_data)
  rescue Crefo::Service::Response::ResponseError => exception
    error = true
  rescue Exception => exception
    error = %(#{exception.class}: #{exception.message}\n#{exception.backtrace.join("\n")})
    raise exception
  end

  Crefo::Log.new(url, (request && request.envelope), (response && response.body), error)
  Result.new(
    result: (response && response.result),
    body: (response && response.body),
    attachments: (response && response.attachments),
    error: error
  )
end