Sha256: 37dd058e710f1549f15606de18826789e22f27d5ae45ec31edffcd758b51840f

Contents?: true

Size: 1.12 KB

Versions: 4

Compression:

Stored size: 1.12 KB

Contents

# Upgrading to chartmogul-ruby 4.0.0

This new version replaces the existing pagination for the `.all()` endpoints that used a combination
of `page` and `per_page` parameters, and instead uses a `cursor` based pagination. So to list
(as an example) Plans you now can:

```ruby
ChartMogul.api_key = '<API key goes here>'

# Getting the first page
plans = ChartMogul::Plan.all(per_page: 12)
```

This will return an array of plans (if available), and a cursor + has_more fields:

```json
{
    "plans": [
        {
            "uuid": "some_uuid",
            "data_source_uuid": "some_uuid",
            "name": "Master Plan"
        }
    ],
    "has_more": true,
    "cursor": "MjAyMy0wNy0yOFQwODowOToyMi4xNTQyMDMwMDBaJjk0NDQ0Mg=="
}
```

```ruby
# You can get the following pages by passing a cursor to .all
if plans.has_more
  more_plans = ChartMogul::Plan.all(per_page: 12, cursor: plans.cursor)
end

# Or by calling .next on the result
if plans.has_more
  more_plans = plans.next(per_page: 3)
end
```

If you have existing code that relies on the `page` parameter, those requests will now throw an error
alerting you of their deprecation.

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
chartmogul-ruby-4.4.0 4.0-Upgrade.md
chartmogul-ruby-4.3.0 4.0-Upgrade.md
chartmogul-ruby-4.2.0 4.0-Upgrade.md
chartmogul-ruby-4.1.0 4.0-Upgrade.md