Class: SpreeBoxnow::PrintVouchers

Inherits:
Object
  • Object
show all
Defined in:
app/services/spree_boxnow/print_vouchers.rb

Defined Under Namespace

Classes: VoucherError

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(parcel_id) ⇒ PrintVouchers

Returns a new instance of PrintVouchers.



5
6
7
# File 'app/services/spree_boxnow/print_vouchers.rb', line 5

def initialize(parcel_id)
  @parcel_id = parcel_id
end

Instance Attribute Details

#parcel_idObject (readonly)

Returns the value of attribute parcel_id.



3
4
5
# File 'app/services/spree_boxnow/print_vouchers.rb', line 3

def parcel_id
  @parcel_id
end

Instance Method Details

#callObject



9
10
11
12
13
# File 'app/services/spree_boxnow/print_vouchers.rb', line 9

def call
  SpreeBoxnow::ApiClient.new.fetch_label(parcel_id, format: 'pdf')
rescue SpreeBoxnow::ApiClient::ApiError => e
  raise VoucherError, e.message
end