Its been a while
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
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
|
||||
Reference in New Issue
Block a user