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) ⇒ 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) ⇒ BasePanel
Returns a new instance of BasePanel.
17 18 19 20 21 |
# File 'lib/usps/imis/panels/base_panel.rb', line 17 def initialize(api = nil, imis_id: nil) @api = api || Api.new @api.imis_id = imis_id if imis_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
106 107 108 |
# File 'lib/usps/imis/panels/base_panel.rb', line 106 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
103 |
# File 'lib/usps/imis/panels/base_panel.rb', line 103 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
33 |
# File 'lib/usps/imis/panels/base_panel.rb', line 33 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
43 |
# File 'lib/usps/imis/panels/base_panel.rb', line 43 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
54 |
# File 'lib/usps/imis/panels/base_panel.rb', line 54 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
112 |
# File 'lib/usps/imis/panels/base_panel.rb', line 112 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
94 |
# File 'lib/usps/imis/panels/base_panel.rb', line 94 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
85 |
# File 'lib/usps/imis/panels/base_panel.rb', line 85 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
65 |
# File 'lib/usps/imis/panels/base_panel.rb', line 65 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
75 |
# File 'lib/usps/imis/panels/base_panel.rb', line 75 def put_fields(ordinal, fields) = api.on(business_object_name, ordinal:).put_fields(fields) |