<commit_before># engaging_networks

A ruby binding for the Engaging Networks API

[![Build Status](https://travis-ci.org/controlshift/ruby_engaging_networks.svg)](https://travis-ci.org/controlshift/ruby_engaging_networks)

## Usage

create a client object

```ruby
require 'engaging_networks'
en = EngagingNetworks.new({public_token: 'PUBLIC_TOKEN',private_token: 'PRIVATE_TOKEN'})
```

Get a campaign by id

```ruby
campaign = en.campaign.get 456
campaign.obj
=> #<EngagingNetworks::Response::Object:0x00000101685f68
 @fields=
  {"clientId"=>"123",
   "campaignId"=>"456",
   "campaignStatus"=>"Live",
   "campaignName"=>"Test Campaign",
   "campaignExportName"=>"Test Campaign",
   "description"=>nil}>
```

Duplicate a campaign


```ruby
action = en.campaign.duplicate reference_name: 'foo',
                      format_name: 'API New Supporter Template',
                      csv_string: 'Email,First Name,Last Name,City,Country Code,Country Name,Postal Code,Mobile Phone,Language,Originating Action',
                      csv_file_name: 'upload.csv',
                      segment_id: 'Test Segment Id',
                      segment_name: 'Test Segment',
                      template_campaign_id: 26967,
                      new_campaign_reference_name: 'New Test Campaign4'
action.job_id
=> '1234'
```

Search for a campaign by name (exact match only)

```ruby
action = en.campaign.search "Foo"
action.campaignName
=> 'Foo'
```

check if supporter exists

```ruby
en.supporter.exists? '<EMAIL>'
=> false
```
create an action

```ruby
action = en.action.create(client_id: 123, campaign_id: 123, form_id: 123, first_name: 'George',
                          last_name: 'Washington', city: 'Detroit', country: country_code, country_name: '<NAME>',
                          email: '<EMAIL>', address_line_1: 'address1', address_line_2: 'address2',
                          post_code: '02052', state: 'MI', mobile_phone: '518-207-6768', originating_action: 'xxx',
                          additional_fields: {'Some Custom Field Name': 'field value'})

action.valid?
=> true
action.result
=> true
```

And then check again, and now supporter exists!

```ruby
en.supporter.exists? '<EMAIL>'
=> true
```

Supporters by date

```
en.supporter.export Date.new(2014,6,5)
=> [{...}]

```

## Copyright

Copyright (c) 2014 ControlShift Ltd. See LICENSE.txt for
further details.

<commit_msg>add opt_in to readme.<commit_after># engaging_networks

A ruby binding for the Engaging Networks API

[![Build Status](https://travis-ci.org/controlshift/ruby_engaging_networks.svg)](https://travis-ci.org/controlshift/ruby_engaging_networks)

## Usage

create a client object

```ruby
require 'engaging_networks'
en = EngagingNetworks.new({public_token: 'PUBLIC_TOKEN',private_token: 'PRIVATE_TOKEN'})
```

Get a campaign by id

```ruby
campaign = en.campaign.get 456
campaign.obj
=> #<EngagingNetworks::Response::Object:0x00000101685f68
 @fields=
  {"clientId"=>"123",
   "campaignId"=>"456",
   "campaignStatus"=>"Live",
   "campaignName"=>"Test Campaign",
   "campaignExportName"=>"Test Campaign",
   "description"=>nil}>
```

Duplicate a campaign


```ruby
action = en.campaign.duplicate reference_name: 'foo',
                      format_name: 'API New Supporter Template',
                      csv_string: 'Email,First Name,Last Name,City,Country Code,Country Name,Postal Code,Mobile Phone,Language,Originating Action',
                      csv_file_name: 'upload.csv',
                      segment_id: 'Test Segment Id',
                      segment_name: 'Test Segment',
                      template_campaign_id: 26967,
                      new_campaign_reference_name: 'New Test Campaign4'
action.job_id
=> '1234'
```

Search for a campaign by name (exact match only)

```ruby
action = en.campaign.search "Foo"
action.campaignName
=> 'Foo'
```

check if supporter exists

```ruby
en.supporter.exists? '<EMAIL>'
=> false
```
create an action

```ruby
action = en.action.create(client_id: 123, campaign_id: 123, form_id: 123, first_name: 'George',
                          last_name: 'Washington', city: 'Detroit', country: country_code, country_name: 'United States',
                          email: '<EMAIL>', address_line_1: 'address1', address_line_2: 'address2',
                          post_code: '02052', state: 'MI', mobile_phone: '518-207-6768', originating_action: 'xxx',
                          opt_in: true,
                          additional_fields: {'Some Custom Field Name': 'field value'})

action.valid?
=> true
action.result
=> true
```

The truth of the opt_in field determines whether or not the member is opted in.

And then check again, and now supporter exists!

```ruby
en.supporter.exists? '<EMAIL>'
=> true
```

Supporters by date

```
en.supporter.export Date.new(2014,6,5)
=> [{...}]

```

## Copyright

Copyright (c) 2014 ControlShift Ltd. See LICENSE.txt for
further details.


{'fraction_non_alphanumeric': 0.13444354183590576, 'fraction_numerical': 0.028838342810722988, 'mean_word_length': 3.293809938971229, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 40, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '996351', 'n_tokens_mistral': 1701, 'n_tokens_neox': 1492, 'n_words': 381}