Class: DynamicPDFApi::PdfXmp
- Defined in:
- lib/ruby_client/PdfXmp.rb
Instance Attribute Summary
Attributes inherited from Endpoint
#_endpoint_name, #api_key, #base_url
Instance Method Summary collapse
-
#initialize(resource) ⇒ PdfXmp
constructor
Initializes a new instance of the PdfInfo class.
-
#process ⇒ Object
Process the pdf resource to get pdf’s xmp data.
Methods inherited from Endpoint
Constructor Details
#initialize(resource) ⇒ PdfXmp
Initializes a new instance of the PdfInfo class.
12 13 14 15 16 |
# File 'lib/ruby_client/PdfXmp.rb', line 12 def initialize(resource) super() @resource = resource @_endpoint_name = 'pdf-xmp' end |
Instance Method Details
#process ⇒ Object
Process the pdf resource to get pdf’s xmp data.
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/ruby_client/PdfXmp.rb', line 23 def process header = { 'Authorization': "Bearer #{@api_key}", 'Content-Length': @resource.data.length.to_s, 'Expect': '100-continue', 'Content-Type': 'application/pdf' } uri = URI.parse("#{@base_url}/v1.0/#{@_endpoint_name}") request = Net::HTTP::Post.new(uri.request_uri, header) = { use_ssl: uri.scheme == 'https', verify_mode: OpenSSL::SSL::VERIFY_NONE } request.content_type = 'application/pdf' request.body = @resource.data response = Net::HTTP.start(uri.hostname, uri.port, ) do |http| http.request(request) end out_data = response.body ret_object = XmlResponse.new(out_data) ret_object.is_successful = false ret_object.status_code = response.code if ret_object.status_code == '200' ret_object.is_successful = true else out_data_json = JSON.parse(out_data) ret_object.error_json = out_data ret_object. = if !out_data_json['message'].nil? out_data_json['message'] else "status_code : #{Net::HTTPResponse::CODE_TO_OBJ[ret_object.status_code]}" end ret_object.error_id = out_data_json['id'] end ret_object end |