Class: FfcrmEndpoint::Endpoint

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(request) ⇒ Endpoint

Returns a new instance of Endpoint.



14
15
16
17
18
# File 'lib/ffcrm_endpoint/endpoint.rb', line 14

def initialize(request)
  @request = request
  @params = request.params
  raise EndpointNoActionError, "No action defined." unless params[:klass_name].present?
end

Instance Attribute Details

#paramsObject

Returns the value of attribute params.



9
10
11
# File 'lib/ffcrm_endpoint/endpoint.rb', line 9

def params
  @params
end

#requestObject

Returns the value of attribute request.



9
10
11
# File 'lib/ffcrm_endpoint/endpoint.rb', line 9

def request
  @request
end

Instance Method Details

#authenticateObject

The authentication method is called by the endpoint controller before ‘process’ is run. ‘process’ will only be called if authenticate returns true



30
31
32
# File 'lib/ffcrm_endpoint/endpoint.rb', line 30

def authenticate
  klass.new(request).authenticate == true
end

#processObject

The main function to process the incoming data. It delegates to the process function in your custom endpoint class.



23
24
25
# File 'lib/ffcrm_endpoint/endpoint.rb', line 23

def process
  klass.new(request).process
end