Class: Bitly::API::Group::Preferences
- Inherits:
-
Object
- Object
- Bitly::API::Group::Preferences
- Includes:
- Base
- Defined in:
- lib/bitly/api/group/preferences.rb
Overview
The Preferences object represents the account preferences of a Group. It includes the ability to find the domain preference for the group and to update it.
Instance Attribute Summary
Attributes included from Base
Class Method Summary collapse
-
.attributes ⇒ Array<Symbol>
The attributes the API returns for a group.
-
.fetch(client:, group_guid:) ⇒ Bitly::API::Group::Preferences
Retrieve the preferences for a Group, given by the group guid.
Instance Method Summary collapse
-
#initialize(data:, client:, response: nil) ⇒ Preferences
constructor
Creates a new Bitly::API::Group::Preferences object from the data, API client and optional response.
-
#update(domain_preference:) ⇒ Bitly::API::Group::Preferences
Updates the preferences via the API [‘PATCH /v4/groups/group_guid/preferences`](dev.bitly.com/api-reference/#updateGroupPreferences).
Methods included from Base
Constructor Details
#initialize(data:, client:, response: nil) ⇒ Preferences
Creates a new Bitly::API::Group::Preferences object from the data, API client and optional response. [‘GET /v4/groups/group_guid/preferences`](dev.bitly.com/api-reference/#updateGroupPreferences)
44 45 46 47 48 |
# File 'lib/bitly/api/group/preferences.rb', line 44 def initialize(data:, client:, response: nil) assign_attributes(data) @client = client @response = response end |
Class Method Details
.attributes ⇒ Array<Symbol>
Returns The attributes the API returns for a group.
15 |
# File 'lib/bitly/api/group/preferences.rb', line 15 def self.attributes ; [:group_guid, :domain_preference] ; end |
.fetch(client:, group_guid:) ⇒ Bitly::API::Group::Preferences
Retrieve the preferences for a Group, given by the group guid
28 29 30 31 |
# File 'lib/bitly/api/group/preferences.rb', line 28 def self.fetch(client:, group_guid:) response = client.request(path: "/groups/#{group_guid}/preferences") new(data: response.body, client: client, response: response) end |
Instance Method Details
#update(domain_preference:) ⇒ Bitly::API::Group::Preferences
Updates the preferences via the API [‘PATCH /v4/groups/group_guid/preferences`](dev.bitly.com/api-reference/#updateGroupPreferences)
61 62 63 64 65 66 67 68 69 |
# File 'lib/bitly/api/group/preferences.rb', line 61 def update(domain_preference:) @response = @client.request( path: "/groups/#{group_guid}/preferences", method: "PATCH", params: { domain_preference: domain_preference } ) assign_attributes(response.body) self end |