Skip to content

Commit

Permalink
field relationship added
Browse files Browse the repository at this point in the history
  • Loading branch information
anmol-yousaf committed May 25, 2021
1 parent 172473a commit 555fdce
Show file tree
Hide file tree
Showing 5 changed files with 284 additions and 1 deletion.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,12 @@ client.custom_fields.all
**QUERY PARAMS** (Optional)
- limit (integer): The number of fields returned per request.

#### Link a custom field to a list

```ruby
client.custom_fields.link_to_list(field_id, list_id)
```

<a name="custom-field-options"/>

### Custom Fields Options - [Api Reference](https://developers.activecampaign.com/reference#create-custom-field-options)
Expand Down
10 changes: 10 additions & 0 deletions lib/active_campaign_wrapper/core/custom_field_gateway.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,16 @@ def update(field_id, params)
def find(field_id)
@config.get("/fields/#{field_id}")
end

def link_to_list(field_id, list_id)
params = { field_rel: { field: field_id, relid: list_id } }
@config.post(
'/fieldRels',
body: ActiveCampaignWrapper::Helpers.normalize_body(
params
)
)
end
end
end
end
2 changes: 1 addition & 1 deletion lib/active_campaign_wrapper/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module ActiveCampaignWrapper
VERSION = '0.5.1'
VERSION = '0.6.0'
end

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions spec/lib/active_campaign_wrapper/core/custom_field_gateway_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,16 @@
expect(response).to eq({})
end
end

describe '#link_to_list', :with_text_field_params, :with_existing_list do
subject(:response) { custom_field_gateway.link_to_list(new_custom_field_id, list_id) }

let!(:new_custom_field_id) do
custom_field_gateway.create(field_params).dig(:field, :id)
end

it 'returns a field_rel hash' do
expect(response).to include_json(field_rel: { relid: list_id, field: new_custom_field_id })
end
end
end

0 comments on commit 555fdce

Please sign in to comment.