Class: CDEKApiClient::API::Print

Inherits:
Object
  • Object
show all
Defined in:
lib/cdek_api_client/api/print.rb

Overview

Handles print-related API requests (barcodes and invoices).

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ Print

Initializes the Print object.

Parameters:



10
11
12
# File 'lib/cdek_api_client/api/print.rb', line 10

def initialize(client)
  @client = client
end

Instance Method Details

#create_barcode(barcode_data) ⇒ Hash

Creates a barcode for an order.

Parameters:

Returns:

  • (Hash)

    the response from the API.



18
19
20
21
# File 'lib/cdek_api_client/api/print.rb', line 18

def create_barcode(barcode_data)
  response = @client.request('post', 'print/barcodes', body: barcode_data)
  handle_response(response)
end

#create_invoice(invoice_data) ⇒ Hash

Creates an invoice for an order.

Parameters:

Returns:

  • (Hash)

    the response from the API.



45
46
47
48
# File 'lib/cdek_api_client/api/print.rb', line 45

def create_invoice(invoice_data)
  response = @client.request('post', 'print/orders', body: invoice_data)
  handle_response(response)
end

#get_barcode(barcode_uuid) ⇒ Hash

Gets barcode information by UUID.

Parameters:

  • barcode_uuid (String)

    the UUID of the barcode.

Returns:

  • (Hash)

    the barcode information.



27
28
29
30
# File 'lib/cdek_api_client/api/print.rb', line 27

def get_barcode(barcode_uuid)
  response = @client.request('get', "print/barcodes/#{barcode_uuid}")
  handle_response(response)
end

#get_barcode_pdf(barcode_uuid) ⇒ String

Gets barcode PDF by UUID.

Parameters:

  • barcode_uuid (String)

    the UUID of the barcode.

Returns:

  • (String)

    the PDF content.



36
37
38
39
# File 'lib/cdek_api_client/api/print.rb', line 36

def get_barcode_pdf(barcode_uuid)
  response = @client.request('get', "print/barcodes/#{barcode_uuid}.pdf")
  handle_binary_response(response)
end

#get_invoice(invoice_uuid) ⇒ Hash

Gets invoice information by UUID.

Parameters:

  • invoice_uuid (String)

    the UUID of the invoice.

Returns:

  • (Hash)

    the invoice information.



54
55
56
57
# File 'lib/cdek_api_client/api/print.rb', line 54

def get_invoice(invoice_uuid)
  response = @client.request('get', "print/orders/#{invoice_uuid}")
  handle_response(response)
end

#get_invoice_pdf(invoice_uuid) ⇒ String

Gets invoice PDF by UUID.

Parameters:

  • invoice_uuid (String)

    the UUID of the invoice.

Returns:

  • (String)

    the PDF content.



63
64
65
66
# File 'lib/cdek_api_client/api/print.rb', line 63

def get_invoice_pdf(invoice_uuid)
  response = @client.request('get', "print/orders/#{invoice_uuid}.pdf")
  handle_binary_response(response)
end