class MakeFilmwebRequest
Constants
- API_KEY
- API_URL
- API_VERSION
- APP_PLATFORM
- HEADERS
Attributes
attribute_values[R]
method[R]
Public Class Methods
new(method:, **attributes)
click to toggle source
# File lib/filmweb_api/services/make_filmweb_request.rb, line 20 def initialize(method:, **attributes) @method = method @attribute_values = attributes.values.join(", ") end
Public Instance Methods
call()
click to toggle source
# File lib/filmweb_api/services/make_filmweb_request.rb, line 25 def call cleaned_response_body end
Private Instance Methods
api_response_body()
click to toggle source
# File lib/filmweb_api/services/make_filmweb_request.rb, line 54 def api_response_body @api_response_body ||= RestClient.get(API_URL, params: request_params, headers: HEADERS).body end
brackets_data_from_response()
click to toggle source
# File lib/filmweb_api/services/make_filmweb_request.rb, line 44 def brackets_data_from_response raise ActionController::RoutingError, 'Not Found' unless api_response_body[/\[.*?\]/].present? api_response_body[/\[.*?\]/].gsub!('[', '').gsub!(']', '').gsub!("null", "") end
cleaned_response_body()
click to toggle source
# File lib/filmweb_api/services/make_filmweb_request.rb, line 40 def cleaned_response_body @cleaned_response_body = brackets_data_from_response.parse_csv end
generate_signature()
click to toggle source
# File lib/filmweb_api/services/make_filmweb_request.rb, line 49 def generate_signature action_request = method + " [#{attribute_values}]" + "\\n" + APP_PLATFORM + API_KEY API_VERSION + "," + Digest::MD5.hexdigest(action_request) end
request_params()
click to toggle source
# File lib/filmweb_api/services/make_filmweb_request.rb, line 31 def request_params { version: API_VERSION, appId: APP_PLATFORM, methods: "#{method} [#{attribute_values}]\\n", signature: generate_signature } end