Files
api/app/services/employers_service/id_cards.rb
T

41 lines
1.2 KiB
Ruby
Raw Normal View History

2026-07-23 10:41:46 -04:00
module EmployersService
class IdCards
def initialize(pl_plan_key)
@employer = Baclight::Employer.find_by(pl_plan_key: pl_plan_key)
if @employer.present?
@pl_plan_key = pl_plan_key
else
raise ArgumentError, "Member not found."
end
end
def call
url_components = {
host: ENV["BACLIGHT_SERVER_HOST"],
port: ENV["BACLIGHT_SERVER_PORT"],
path: "/api/v1/web_id_cards/employer_cards/#{@pl_plan_key}"
}
response = HTTParty.get(
URI::HTTP.build(url_components),
headers: { 'Content-Type' => 'application/json', 'Accept' => 'application/zip' },
stream_body: true
)
if response.code == 200
# content_disposition = response.headers['Content-Disposition']
# {
# zip_file: response.body,
# filename: content_disposition[/filename="?([^"]*)"?/, 1]
# }
response
else
nil
end
end
end
end