Class: CzechPostB2bClient::ResponseParsers::GetParcelsPrintingParser
- Inherits:
-
BaseParser
show all
- Defined in:
- lib/czech_post_b2b_client/response_parsers/get_parcels_printing_parser.rb
Instance Attribute Summary
#result
Instance Method Summary
collapse
Methods inherited from BaseParser
#initialize, #steps
call, #call, #errors, #failure?, #finished?, #steps, #success?
Instance Method Details
#build_result ⇒ Object
8
9
10
11
12
13
|
# File 'lib/czech_post_b2b_client/response_parsers/get_parcels_printing_parser.rb', line 8
def build_result
super
@result[:response][:state] = state_hash_from(.dig('doPrintingStateResponse'))
@result[:printings] = { options: options_hash,
pdf_content: pdf_content }
end
|
#options_hash ⇒ Object
15
16
17
18
19
20
21
22
23
24
25
|
# File 'lib/czech_post_b2b_client/response_parsers/get_parcels_printing_parser.rb', line 15
def options_hash
options_response = .dig('doPrintingHeader')
{
customer_id: options_response.dig('customerID'),
contract_number: options_response.dig('contractNumber'),
template_id: options_response.dig('idForm').to_i,
margin_in_mm: { top: options_response.dig('shiftVertical').to_i,
left: options_response.dig('shiftHorizontal').to_i },
position_order: options_response.dig('position').to_i
}
end
|
#pdf_content ⇒ Object
27
28
29
30
31
32
|
# File 'lib/czech_post_b2b_client/response_parsers/get_parcels_printing_parser.rb', line 27
def pdf_content
pdf_content_encoded = response_root_node.dig('doPrintingDataResult', 'file')
return nil if pdf_content_encoded.nil?
::Base64.decode64(pdf_content_encoded)
end
|
38
39
40
|
# File 'lib/czech_post_b2b_client/response_parsers/get_parcels_printing_parser.rb', line 38
def
response_root_node.dig('doPrintingHeaderResult')
end
|
#response_root_node_name ⇒ Object
34
35
36
|
# File 'lib/czech_post_b2b_client/response_parsers/get_parcels_printing_parser.rb', line 34
def response_root_node_name
'getParcelsPrintingResponse'
end
|