Class: SnapchatApi::Resources::Account

Inherits:
Base
  • Object
show all
Defined in:
lib/snapchat_api/resources/account.rb

Instance Attribute Summary

Attributes inherited from Base

#client

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from SnapchatApi::Resources::Base

Instance Method Details

#list_all(organization_id:, params: {}) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/snapchat_api/resources/account.rb', line 4

def list_all(organization_id:, params: {})
  params[:limit] ||= 50

  accounts = []
  next_link = "organizations/#{organization_id}/adaccounts?limit=#{params[:limit]}"

  loop do
    response = client.request(:get, next_link)
    next_link = response.body["paging"]["next_link"]
    accounts.concat(response.body["adaccounts"].map { |el| el["adaccount"] })
    break if next_link.nil?
  end

  accounts
end