Its been a while
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
module MembersService
|
||||
class IdCard
|
||||
|
||||
def initialize(member, layout)
|
||||
@member = member
|
||||
if @member.present?
|
||||
@pb_entity_key = @member.pb_entity_key
|
||||
@layout = layout
|
||||
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/member_card/#{@pb_entity_key}/#{@layout}"
|
||||
}
|
||||
|
||||
response = HTTParty.get(
|
||||
URI::HTTP.build(url_components),
|
||||
headers: { 'Content-Type' => 'application/json', 'Accept' => 'application/pdf' },
|
||||
stream_body: true
|
||||
)
|
||||
|
||||
if response.code == 200
|
||||
# content_disposition = response.headers['Content-Disposition']
|
||||
# {
|
||||
# pdf_file: response.body,
|
||||
# filename: content_disposition[/filename="?([^"]*)"?/, 1]
|
||||
# }
|
||||
|
||||
response
|
||||
else
|
||||
nil
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user