Class: PayPal::SDK::REST::DataTypes::Template

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

.get(template_id, options = {}) ⇒ Object

Raises:

  • (ArgumentError)

1372
1373
1374
1375
1376
# File 'lib/paypal-sdk/rest/data_types.rb', line 1372

def get(template_id, options = {})
  raise ArgumentError.new("template_id required") if template_id.to_s.strip.empty?
  path = "v1/invoicing/templates/#{template_id}"
  self.new(api.get(path, options))
end

.load_membersObject


1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
# File 'lib/paypal-sdk/rest/data_types.rb', line 1337

def self.load_members
     object_of :template_id, String
     object_of :name, String
     object_of :default, Boolean
     object_of :template_data, TemplateData
     array_of  :settings, TemplateSettings
     object_of :unit_of_measure, String
     object_of :custom, Boolean
     array_of  :links, Links
end

Instance Method Details

#createObject


1364
1365
1366
1367
1368
1369
# File 'lib/paypal-sdk/rest/data_types.rb', line 1364

def create()
    path = "v1/invoicing/templates"
    response = api.post(path, self.to_hash, http_header)
    self.merge!(response)
    Template.new(response)
end

#deleteObject


1350
1351
1352
1353
1354
1355
# File 'lib/paypal-sdk/rest/data_types.rb', line 1350

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

#updateObject


1357
1358
1359
1360
1361
1362
# File 'lib/paypal-sdk/rest/data_types.rb', line 1357

def update()
  path = "v1/invoicing/templates/#{self.template_id}"
  response = api.put(path, self.to_hash, http_header)
  self.merge!(response)
  Template.new(response)
end