Class: Usps::Imis::Panels::BasePanel
- Inherits:
-
Object
- Object
- Usps::Imis::Panels::BasePanel
- Defined in:
- lib/usps/imis/panels/base_panel.rb
Overview
Base class for configuring Panels
Instance Attribute Summary collapse
-
#api ⇒ Object
readonly
The parent
Apiobject. -
#logger ⇒ Object
readonly
Tagged logger.
Instance Method Summary collapse
- #business_object_name ⇒ Object
-
#delete(ordinal) ⇒ true
(also: #destroy)
Remove a specific object from the Panel.
-
#get(ordinal, *fields) ⇒ Usps::Imis::Data+
(also: #read)
Get a specific object from the Panel.
-
#get_field(ordinal, field) ⇒ Object
(also: #fetch, #[])
Get a single named field from a Panel for the current member.
-
#get_fields(ordinal, *fields) ⇒ Array
(also: #fetch_all)
Get named fields from a Panel for the current member.
-
#initialize(api = nil, imis_id: nil, record_id: nil) ⇒ BasePanel
constructor
A new instance of BasePanel.
-
#instance_variables_to_inspect ⇒ Object
Ruby 3.5 instance variable filter.
-
#post(data) ⇒ Usps::Imis::Data
(also: #create)
Create a new object in the Panel.
-
#put(data) ⇒ Usps::Imis::Data
(also: #update)
Update an existing object in the Panel.
-
#put_field(ordinal, field, value) ⇒ Usps::Imis::Data
(also: #[]=)
Update a single named field on a business object for the current member.
-
#put_fields(ordinal, fields) ⇒ Usps::Imis::Data
(also: #patch)
Update only specific fields on a Panel for the current member.
Constructor Details
#initialize(api = nil, imis_id: nil, record_id: nil) ⇒ BasePanel
Returns a new instance of BasePanel.
17 18 19 20 21 22 |
# File 'lib/usps/imis/panels/base_panel.rb', line 17 def initialize(api = nil, imis_id: nil, record_id: nil) @api = api || Api.new @api.imis_id = imis_id if imis_id @api.record_id = record_id if record_id @logger = Imis.logger('Panel') end |
Instance Attribute Details
#api ⇒ Object (readonly)
The parent Api object
11 12 13 |
# File 'lib/usps/imis/panels/base_panel.rb', line 11 def api @api end |
#logger ⇒ Object (readonly)
Tagged logger
15 16 17 |
# File 'lib/usps/imis/panels/base_panel.rb', line 15 def logger @logger end |
Instance Method Details
#business_object_name ⇒ Object
107 108 109 |
# File 'lib/usps/imis/panels/base_panel.rb', line 107 def business_object_name raise Errors::PanelUnimplementedError.from(self.class.name, 'business_object_name') end |
#delete(ordinal) ⇒ true Also known as: destroy
Remove a specific object from the Panel
104 |
# File 'lib/usps/imis/panels/base_panel.rb', line 104 def delete(ordinal) = api.on(business_object_name, ordinal:).delete |
#get(ordinal, *fields) ⇒ Usps::Imis::Data+ Also known as: read
Get a specific object from the Panel
If fields is provided, will return only those field values
34 |
# File 'lib/usps/imis/panels/base_panel.rb', line 34 def get(ordinal, *fields) = api.on(business_object_name, ordinal:).get(*fields) |
#get_field(ordinal, field) ⇒ Object Also known as: fetch, []
Get a single named field from a Panel for the current member
44 |
# File 'lib/usps/imis/panels/base_panel.rb', line 44 def get_field(ordinal, field) = api.on(business_object_name, ordinal:).get_field(field) |
#get_fields(ordinal, *fields) ⇒ Array Also known as: fetch_all
Get named fields from a Panel for the current member
55 |
# File 'lib/usps/imis/panels/base_panel.rb', line 55 def get_fields(ordinal, *fields) = api.on(business_object_name, ordinal:).get_fields(*fields) |
#instance_variables_to_inspect ⇒ Object
Ruby 3.5 instance variable filter
113 |
# File 'lib/usps/imis/panels/base_panel.rb', line 113 def instance_variables_to_inspect = instance_variables - %i[@api @logger] |
#post(data) ⇒ Usps::Imis::Data Also known as: create
Create a new object in the Panel
95 |
# File 'lib/usps/imis/panels/base_panel.rb', line 95 def post(data) = api.on(business_object_name).post(payload(data)) |
#put(data) ⇒ Usps::Imis::Data Also known as: update
Update an existing object in the Panel
86 |
# File 'lib/usps/imis/panels/base_panel.rb', line 86 def put(data) = api.on(business_object_name, ordinal: data[:ordinal]).put(payload(data)) |
#put_field(ordinal, field, value) ⇒ Usps::Imis::Data Also known as: []=
Update a single named field on a business object for the current member
66 |
# File 'lib/usps/imis/panels/base_panel.rb', line 66 def put_field(ordinal, field, value) = api.on(business_object_name, ordinal:).put_field(field, value) |
#put_fields(ordinal, fields) ⇒ Usps::Imis::Data Also known as: patch
Update only specific fields on a Panel for the current member
76 |
# File 'lib/usps/imis/panels/base_panel.rb', line 76 def put_fields(ordinal, fields) = api.on(business_object_name, ordinal:).put_fields(fields) |