class ONEAccess::API::V3_0::Interactions

Constants

DATE_FORMAT
DATE_FORMAT_REGEX

Public Class Methods

buy_side_interactions( type:, start_date:, end_date:, user_id:, broker:, company_name:, email: ) click to toggle source
# File lib/oneaccess/api/v3_0/interactions.rb, line 23
def buy_side_interactions(
  type:,
  start_date:,
  end_date:,
  user_id:,
  broker:,
  company_name:,
  email:
)

  validate_date(start_date)
  validate_date(end_date)

  response = send_post(
    'buysideinteractions',
    payload(type, start_date, end_date, user_id, broker, company_name, email),
  )

  Response::BuySideInteractionsResponse.from_json(response.body)
end

Private Class Methods

payload(type, start_date, end_date, user_id, broker, company_name, email) click to toggle source
# File lib/oneaccess/api/v3_0/interactions.rb, line 65
def payload(type, start_date, end_date, user_id, broker, company_name, email)
  {
    start_date:         start_date,
    end_date:           end_date,
    user_id:            user_id.to_s,
    interaction_type:   type,
    broker:             broker.to_s,
    investor:           company_name.to_s,
    investor_attendees: [{ email: email }],
  }
end
valid_date?(date_str, format = DATE_FORMAT) click to toggle source
# File lib/oneaccess/api/v3_0/interactions.rb, line 53
def valid_date?(date_str, format = DATE_FORMAT)
  Date.strptime(date_str, format)

  true
rescue StandardError
  false
end
valid_date_format?(date_str) click to toggle source
# File lib/oneaccess/api/v3_0/interactions.rb, line 61
def valid_date_format?(date_str)
  date_str.match?(DATE_FORMAT_REGEX)
end
validate_date(date_str) click to toggle source
# File lib/oneaccess/api/v3_0/interactions.rb, line 46
def validate_date(date_str)
  raise "Invalid format, must be: yyyy-mm-dd hh:mm, was: #{date_str}" unless valid_date_format?(date_str)
  raise "Invalid date: #{date_str}" unless valid_date?(date_str)

  nil
end