Sha256: be6205aec50ec3fd5489d98e362f570d72f1b51eeac0167bf883ae06c28e3931

Contents?: true

Size: 1.45 KB

Versions: 1

Compression:

Stored size: 1.45 KB

Contents

# Gladwords

A saner Ruby wrapper over the AdWords API, using [ROM.rb](https://rom-rb.org).

# Clout

[![CircleCI](https://circleci.com/gh/adHawk/gladwords.svg?style=svg)](https://circleci.com/gh/adHawk/gladwords)

## Usage

```ruby
# setup your client following these instructions:
#   https://github.com/googleads/google-api-ads-ruby/blob/master/adwords_api/README.md#2---using-the-client-library
client = AdwordsApi::Api.new

ROM::Configuration.new(:adwords, client: client) do |config|
  config.relation(:campaigns) do
    auto_struct(true)
    auto_map(true)

    schema(infer: true) do
      attribute :id, Gladwords::Types::ID

      primary_key :id

      associations do
        has_many :ad_groups, combine_key: :campaign_id
      end
    end
  end

  config.relation(:ad_groups) do
    auto_struct(true)
    auto_map(true)

    schema(infer: true) do
      attribute :id, Gladwords::Types::ID

      primary_key :id

      associations do
        belongs_to :campaign, combine_key: :id
      end
    end
  end
end

scope = subject.select(:id, :name).where(name: 'Test Campaign 2')
gladwords = ROM.container(configuration)

# query the relations
campaigns = gladwords.relations[:campaigns]
campaigns.select(:id, :name).where(name: 'Campaign 2').to_a # [{ id: '123', name: 'Campaign 2']]
```

## Installation

Add this line to your application's Gemfile:

```ruby
gem 'attr-gather'
```

And then execute:

    $ bundle

Or install it yourself as:

    $ gem install attr-gather

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
gladwords-1.0.1 README.md