snapchat_api 0.1.6 → 0.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +15 -0
- data/lib/snapchat_api/client.rb +8 -0
- data/lib/snapchat_api/resources/ad_squad.rb +23 -12
- data/lib/snapchat_api/resources/funding_source.rb +27 -0
- data/lib/snapchat_api/resources/organization.rb +27 -0
- data/lib/snapchat_api/version.rb +1 -1
- metadata +3 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 68c01081685c51092fac5d51d23bfdd92783647f615454dba7b1ea42f2ce4796
|
|
4
|
+
data.tar.gz: 36708edcfd4d108effdd48e17a99d7d7c010913b40f0651eb104bc54ea9a7f01
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 4acabf2f1ddf87f1477bfdf509756cc5ae30623b4a9437ce157f8fee964a06916bb5d9f8e9bc9c6b8e9863f158052979dca9dcdd00b6b4d95ddcc23ac6aaae8a
|
|
7
|
+
data.tar.gz: 0f8bdb643cb3a189890eac966912788f0cb7d4da19973f86a26d37798bc87f1382b66f3c127eea45c241d239e96c9fa773f0a16547a1c60477cabc10878c8a8e
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.1.8](https://github.com/k0va1/snapchat_api/compare/v0.1.7...v0.1.8) (2026-01-13)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* add funding sources api ([#15](https://github.com/k0va1/snapchat_api/issues/15)) ([1974240](https://github.com/k0va1/snapchat_api/commit/19742401dd77f4209cccf1be3a0c1cb5e8397ba0))
|
|
9
|
+
* add organizations ([#13](https://github.com/k0va1/snapchat_api/issues/13)) ([920bcc0](https://github.com/k0va1/snapchat_api/commit/920bcc08baee865da03cd174d4937a3dab35a6f0))
|
|
10
|
+
|
|
11
|
+
## [0.1.7](https://github.com/k0va1/snapchat_api/compare/v0.1.6...v0.1.7) (2026-01-13)
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
### Features
|
|
15
|
+
|
|
16
|
+
* add new endpoint for filtering ad squads by campaign ([#11](https://github.com/k0va1/snapchat_api/issues/11)) ([06a1aa3](https://github.com/k0va1/snapchat_api/commit/06a1aa389f69e7757760c26bb17d8a80cf588328))
|
|
17
|
+
|
|
3
18
|
## [0.1.6](https://github.com/k0va1/snapchat_api/compare/v0.1.5...v0.1.6) (2025-12-30)
|
|
4
19
|
|
|
5
20
|
|
data/lib/snapchat_api/client.rb
CHANGED
|
@@ -132,6 +132,14 @@ module SnapchatApi
|
|
|
132
132
|
@ads ||= SnapchatApi::Resources::Ad.new(self)
|
|
133
133
|
end
|
|
134
134
|
|
|
135
|
+
def organizations
|
|
136
|
+
@organizations ||= SnapchatApi::Resources::Organization.new(self)
|
|
137
|
+
end
|
|
138
|
+
|
|
139
|
+
def funding_sources
|
|
140
|
+
@funding_sources ||= SnapchatApi::Resources::FundingSource.new(self)
|
|
141
|
+
end
|
|
142
|
+
|
|
135
143
|
private
|
|
136
144
|
|
|
137
145
|
def handle_response(response)
|
|
@@ -1,20 +1,14 @@
|
|
|
1
|
+
require "uri"
|
|
2
|
+
|
|
1
3
|
module SnapchatApi
|
|
2
4
|
module Resources
|
|
3
5
|
class AdSquad < Base
|
|
4
6
|
def list_all(ad_account_id:, params: {})
|
|
5
|
-
params
|
|
6
|
-
|
|
7
|
-
ad_squads = []
|
|
8
|
-
next_link = "adaccounts/#{ad_account_id}/adsquads?limit=#{params[:limit]}"
|
|
9
|
-
|
|
10
|
-
loop do
|
|
11
|
-
response = client.request(:get, next_link)
|
|
12
|
-
next_link = response.body["paging"]["next_link"]
|
|
13
|
-
ad_squads.concat(response.body["adsquads"].map { |el| el["adsquad"] })
|
|
14
|
-
break if next_link.nil?
|
|
15
|
-
end
|
|
7
|
+
fetch_all_adsquads("adaccounts/#{ad_account_id}/adsquads", params)
|
|
8
|
+
end
|
|
16
9
|
|
|
17
|
-
|
|
10
|
+
def list_all_by_campaign(campaign_id:, params: {})
|
|
11
|
+
fetch_all_adsquads("campaigns/#{campaign_id}/adsquads", params)
|
|
18
12
|
end
|
|
19
13
|
|
|
20
14
|
def get(ad_squad_id:)
|
|
@@ -49,6 +43,23 @@ module SnapchatApi
|
|
|
49
43
|
response = client.request(:get, "adsquads/#{ad_squad_id}/stats", params)
|
|
50
44
|
response.body
|
|
51
45
|
end
|
|
46
|
+
|
|
47
|
+
private
|
|
48
|
+
|
|
49
|
+
def fetch_all_adsquads(base_path, params)
|
|
50
|
+
params[:limit] ||= 50
|
|
51
|
+
ad_squads = []
|
|
52
|
+
next_link = "#{base_path}?#{URI.encode_www_form(params)}"
|
|
53
|
+
|
|
54
|
+
loop do
|
|
55
|
+
response = client.request(:get, next_link)
|
|
56
|
+
next_link = response.body["paging"]["next_link"]
|
|
57
|
+
ad_squads.concat(response.body["adsquads"].map { |el| el["adsquad"] })
|
|
58
|
+
break if next_link.nil?
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
ad_squads
|
|
62
|
+
end
|
|
52
63
|
end
|
|
53
64
|
end
|
|
54
65
|
end
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
module SnapchatApi
|
|
2
|
+
module Resources
|
|
3
|
+
class FundingSource < Base
|
|
4
|
+
def list_all(organization_id:, params: {})
|
|
5
|
+
params[:limit] ||= 50
|
|
6
|
+
|
|
7
|
+
funding_sources = []
|
|
8
|
+
query = URI.encode_www_form(params.compact)
|
|
9
|
+
next_link = "organizations/#{organization_id}/fundingsources?#{query}"
|
|
10
|
+
|
|
11
|
+
loop do
|
|
12
|
+
response = client.request(:get, next_link)
|
|
13
|
+
next_link = response.body.dig("paging", "next_link")
|
|
14
|
+
funding_sources.concat(response.body["fundingsources"].map { |el| el["fundingsource"] })
|
|
15
|
+
break if next_link.nil?
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
funding_sources
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def get(funding_source_id:)
|
|
22
|
+
response = client.request(:get, "fundingsources/#{funding_source_id}")
|
|
23
|
+
response.body["fundingsources"].first["fundingsource"]
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
module SnapchatApi
|
|
2
|
+
module Resources
|
|
3
|
+
class Organization < Base
|
|
4
|
+
def list_all(params: {})
|
|
5
|
+
params[:limit] ||= 50
|
|
6
|
+
|
|
7
|
+
organizations = []
|
|
8
|
+
query = URI.encode_www_form(params.compact)
|
|
9
|
+
next_link = "me/organizations?#{query}"
|
|
10
|
+
|
|
11
|
+
loop do
|
|
12
|
+
response = client.request(:get, next_link)
|
|
13
|
+
next_link = response.body.dig("paging", "next_link")
|
|
14
|
+
organizations.concat(response.body["organizations"].map { |el| el["organization"] })
|
|
15
|
+
break if next_link.nil?
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
organizations
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def get(organization_id:)
|
|
22
|
+
response = client.request(:get, "organizations/#{organization_id}")
|
|
23
|
+
response.body["organizations"].first["organization"]
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
data/lib/snapchat_api/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: snapchat_api
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.8
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Alex Koval
|
|
@@ -212,7 +212,9 @@ files:
|
|
|
212
212
|
- lib/snapchat_api/resources/base.rb
|
|
213
213
|
- lib/snapchat_api/resources/campaign.rb
|
|
214
214
|
- lib/snapchat_api/resources/creative.rb
|
|
215
|
+
- lib/snapchat_api/resources/funding_source.rb
|
|
215
216
|
- lib/snapchat_api/resources/media.rb
|
|
217
|
+
- lib/snapchat_api/resources/organization.rb
|
|
216
218
|
- lib/snapchat_api/version.rb
|
|
217
219
|
homepage: https://github.com/k0va1/snapchat_api
|
|
218
220
|
licenses: []
|