class Credova::FFL

Constants

CREATE_ATTRS
ENDPOINTS

Public Class Methods

new(client) click to toggle source
# File lib/credova/ffl.rb, line 19
def initialize(client)
  @client = client
end

Public Instance Methods

create(ffl_data) click to toggle source
# File lib/credova/ffl.rb, line 23
def create(ffl_data)
  requires!(ffl_data, *CREATE_ATTRS[:required])

  ffl_data[:expiration] = ffl_data[:expiration].strftime('%Y/%m/%d')
  endpoint = ENDPOINTS[:create]
  headers  = [
    *auth_header(@client.access_token),
    *content_type_header('application/json'),
  ].to_h

  ffl_data = standardize_body_data(ffl_data, CREATE_ATTRS[:permitted])

  post_request(endpoint, ffl_data, headers)
end
find(license_number) click to toggle source
# File lib/credova/ffl.rb, line 38
def find(license_number)
  endpoint = ENDPOINTS[:find] % license_number

  get_request(endpoint, auth_header(@client.access_token))
end
upload_document(ffl_public_id, ffl_file_data) click to toggle source
# File lib/credova/ffl.rb, line 44
def upload_document(ffl_public_id, ffl_file_data)
  requires!(ffl_file_data, *FILE_UPLOAD_ATTRS[:required])

  endpoint = ENDPOINTS[:upload_document] % ffl_public_id

  post_file_request(endpoint, ffl_file_data, auth_header(@client.access_token))
end