Skip to content

Commit 555fdce

Browse files
committed
field relationship added
1 parent 172473a commit 555fdce

File tree

5 files changed

+284
-1
lines changed

5 files changed

+284
-1
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -477,6 +477,12 @@ client.custom_fields.all
477477
**QUERY PARAMS** (Optional)
478478
- limit (integer): The number of fields returned per request.
479479

480+
#### Link a custom field to a list
481+
482+
```ruby
483+
client.custom_fields.link_to_list(field_id, list_id)
484+
```
485+
480486
<a name="custom-field-options"/>
481487

482488
### Custom Fields Options - [Api Reference](https://developers.activecampaign.com/reference#create-custom-field-options)

lib/active_campaign_wrapper/core/custom_field_gateway.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,16 @@ def update(field_id, params)
4141
def find(field_id)
4242
@config.get("/fields/#{field_id}")
4343
end
44+
45+
def link_to_list(field_id, list_id)
46+
params = { field_rel: { field: field_id, relid: list_id } }
47+
@config.post(
48+
'/fieldRels',
49+
body: ActiveCampaignWrapper::Helpers.normalize_body(
50+
params
51+
)
52+
)
53+
end
4454
end
4555
end
4656
end
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# frozen_string_literal: true
22

33
module ActiveCampaignWrapper
4-
VERSION = '0.5.1'
4+
VERSION = '0.6.0'
55
end

spec/cassettes/ActiveCampaignWrapper_Core_CustomFieldGateway/_link_to_list/returns_a_field_rel_hash.yml

Lines changed: 255 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

spec/lib/active_campaign_wrapper/core/custom_field_gateway_spec.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,4 +75,16 @@
7575
expect(response).to eq({})
7676
end
7777
end
78+
79+
describe '#link_to_list', :with_text_field_params, :with_existing_list do
80+
subject(:response) { custom_field_gateway.link_to_list(new_custom_field_id, list_id) }
81+
82+
let!(:new_custom_field_id) do
83+
custom_field_gateway.create(field_params).dig(:field, :id)
84+
end
85+
86+
it 'returns a field_rel hash' do
87+
expect(response).to include_json(field_rel: { relid: list_id, field: new_custom_field_id })
88+
end
89+
end
7890
end

0 commit comments

Comments
 (0)