Class: PayPal::SDK::REST::DataTypes::Invoice

Inherits:
Base show all
Includes:
RequestDataType
Defined in:
lib/paypal-sdk/rest/data_types.rb

Constant Summary

Constants inherited from Core::API::DataTypes::Base

Core::API::DataTypes::Base::ContentKey, Core::API::DataTypes::Base::HashOptions

Instance Attribute Summary

Attributes inherited from Base

#error, #header, #request_id

Class Method Summary collapse

Instance Method Summary collapse

Methods included from RequestDataType

#api, api, #error=, included

Methods included from SetAPI

#client_id=, #client_secret=, #set_config, #token=

Methods inherited from Base

#http_header, #merge!, #raise_error!, raise_on_api_error, #success?

Methods inherited from Core::API::DataTypes::Base

add_attribute, add_member, array_of, #convert_array, #convert_object, define_alias_methods, #hash_key, #initialize, #member_names, members, #members, #merge!, object_of, #set, #skip_value?, snakecase, #to_hash, #value_to_hash

Methods included from Core::Logging

#log_event, #logger, logger, logger=

Constructor Details

This class inherits a constructor from PayPal::SDK::Core::API::DataTypes::Base

Class Method Details

.find(resource_id, access_token = nil) ⇒ Object

Raises:

  • (ArgumentError)

1295
1296
1297
1298
1299
1300
# File 'lib/paypal-sdk/rest/data_types.rb', line 1295

def find(resource_id, access_token = nil)
  raise ArgumentError.new("id required") if resource_id.to_s.strip.empty?
  path = "v1/invoicing/invoices/#{resource_id}"
  api.token = access_token unless access_token.nil?
  self.new(api.get(path))
end

.generate_number(options) ⇒ Object


1313
1314
1315
1316
1317
# File 'lib/paypal-sdk/rest/data_types.rb', line 1313

def self.generate_number(options)
  path = "v1/invoicing/invoices/next-invoice-number"
  response = api.post(path, options)
  object.new(response)
end

.get_all(options = {}, access_token = nil) ⇒ Object


1302
1303
1304
1305
1306
# File 'lib/paypal-sdk/rest/data_types.rb', line 1302

def get_all(options = {}, access_token = nil)
  path = "v1/invoicing/invoices/"
  api.token = access_token unless access_token.nil?
  Invoices.new(api.get(path, options))
end

.load_membersObject


1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
# File 'lib/paypal-sdk/rest/data_types.rb', line 1184

def self.load_members
  object_of :id, String
	      object_of :number, String
	      object_of :template_id, String
	      object_of :uri, String
	      object_of :status, String
	      object_of :merchant_info, MerchantInfo
	      array_of  :billing_info, BillingInfo
	      array_of  :cc_info, Participant
	      object_of :shipping_info, ShippingInfo
	      array_of  :items, InvoiceItem
	      object_of :invoice_date, String
	      object_of :payment_term, PaymentTerm
	      object_of :reference, String
	      object_of :discount, Cost
	      object_of :shipping_cost, ShippingCost
	      object_of :custom, CustomAmount
	      object_of :allow_partial_payment, Boolean
	      object_of :minimum_amount_due, Currency
	      object_of :tax_calculated_after_discount, Boolean
	      object_of :tax_inclusive, Boolean
	      object_of :terms, String
	      object_of :note, String
	      object_of :merchant_memo, String
	      object_of :logo_url, String
	      object_of :total_amount, Currency
  array_of  :payments, PaymentDetail
  array_of  :refunds, RefundDetail
	      object_of :metadata, Metadata
	      object_of :additional_data, String
	      object_of :gratuity, Currency
	      object_of :paid_amount, PaymentSummary
	      object_of :refunded_amount, PaymentSummary
  array_of  :attachments, FileAttachment
  array_of  :links, Links
end

.qr_code(options = {}) ⇒ Object


1308
1309
1310
1311
# File 'lib/paypal-sdk/rest/data_types.rb', line 1308

def qr_code(options = {})
  path = "v1/invoicing/invoices/{invoice_id}/qr-code"
  object.new(api.get(path, options))
end

.search(options, access_token = nil) ⇒ Object


1288
1289
1290
1291
1292
1293
# File 'lib/paypal-sdk/rest/data_types.rb', line 1288

def search(options, access_token = nil)
  path = "v1/invoicing/search"
  api.token = access_token unless access_token.nil?
  response = api.post(path, options)
  Invoices.new(response)
end

Instance Method Details

#cancel(cancel_notification) ⇒ Object


1245
1246
1247
1248
1249
1250
1251
# File 'lib/paypal-sdk/rest/data_types.rb', line 1245

def cancel(cancel_notification)
  cancel_notification = CancelNotification.new(cancel_notification) unless cancel_notification.is_a? CancelNotification
  path = "v1/invoicing/invoices/#{self.id}/cancel"
  response = api.post(path, cancel_notification.to_hash, http_header)
  self.merge!(response)
  success?
end

#createObject


1223
1224
1225
1226
1227
1228
# File 'lib/paypal-sdk/rest/data_types.rb', line 1223

def create()
  path = "v1/invoicing/invoices"
  response = api.post(path, self.to_hash, http_header)
  self.merge!(response)
  success?
end

#deleteObject


1276
1277
1278
1279
1280
1281
# File 'lib/paypal-sdk/rest/data_types.rb', line 1276

def delete()
  path = "v1/invoicing/invoices/#{self.id}"
  response = api.delete(path, {})
  self.merge!(response)
  success?
end

#record_payment(payment_detail) ⇒ Object


1253
1254
1255
1256
1257
1258
1259
# File 'lib/paypal-sdk/rest/data_types.rb', line 1253

def record_payment(payment_detail)
  payment_detail = PaymentDetail.new(payment_detail) unless payment_detail.is_a? PaymentDetail
  path = "v1/invoicing/invoices/#{self.id}/record-payment"
  response = api.post(path, payment_detail.to_hash, http_header)
  self.merge!(response)
  success?
end

#record_refund(refund_detail) ⇒ Object


1261
1262
1263
1264
1265
1266
1267
# File 'lib/paypal-sdk/rest/data_types.rb', line 1261

def record_refund(refund_detail)
  refund_detail = RefundDetail.new(refund_detail) unless refund_detail.is_a? RefundDetail
  path = "v1/invoicing/invoices/#{self.id}/record-refund"
  response = api.post(path, refund_detail.to_hash, http_header)
  self.merge!(response)
  success?
end

#remind(notification) ⇒ Object


1237
1238
1239
1240
1241
1242
1243
# File 'lib/paypal-sdk/rest/data_types.rb', line 1237

def remind(notification)
  notification = Notification.new(notification) unless notification.is_a? Notification
  path = "v1/invoicing/invoices/#{self.id}/remind"
  response = api.post(path, notification.to_hash, http_header)
  self.merge!(response)
  success?
end

#send_invoiceObject


1230
1231
1232
1233
1234
1235
# File 'lib/paypal-sdk/rest/data_types.rb', line 1230

def send_invoice()
  path = "v1/invoicing/invoices/#{self.id}/send"
  response = api.post(path, {}, http_header)
  self.merge!(response)
  success?
end

#updateObject


1269
1270
1271
1272
1273
1274
# File 'lib/paypal-sdk/rest/data_types.rb', line 1269

def update()
  path = "v1/invoicing/invoices/#{self.id}"
  response = api.put(path, self.to_hash, http_header)
  self.merge!(response)
  success?
end