socialstats-ruby-sdk 0.1.0 → 0.2.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9913c6eb0102ad42654410100eb2a33fe967ee4d99d0e831b9d34e34b7a02c95
4
- data.tar.gz: 6585f4e2b0bae1eee06e6e8a6aba82124efb9f10495f92a00fc8635f2055f707
3
+ metadata.gz: 9110554befa10042946b632009958a70d7a5829342e7fff405422e12b66c1a1b
4
+ data.tar.gz: 38bb25ee6c5a81a18f8156578212d0bbb09464d150cc5246ca31ec6d4361472d
5
5
  SHA512:
6
- metadata.gz: ca3e3dc6d29ac228a25383015048592efed8a66591e864670cd967f4e16ab340c639552b4c39c53b9250199ec6ff4b9ba401de8f470fcd4368d8a5b33adf869c
7
- data.tar.gz: df8cf7c971eec6f6225d6ae5a4dd896a9256e7ace3fef6e75654f7cee6a5aba8b186157758421f916e04f7c9dbbb31fe550ea1d514797b17b02ee9fc4cd910f2
6
+ metadata.gz: 9baa01b98d81eb46e5dd335f8772a4752489cd059ac1fe68aef98b8739682bea5dd84b4539bc11749e8e540cc890538c0cb95e421f7a65ff893e550cfdd8f075
7
+ data.tar.gz: 4a1def55dfbe45ba7122792a64ab75768679440ae16ec15104419464e3a012e87168f09c2e94eb3ad1683e6798e583308210727d1cb0153e758e9e3ab32a9d04
data/CHANGELOG.md CHANGED
@@ -2,6 +2,14 @@
2
2
 
3
3
  All notable changes to this project are documented in this file.
4
4
 
5
+ ## [0.2.0] - 2026-09-08
6
+
7
+ ### Added
8
+
9
+ - OAuth authorization lifecycle resource coverage
10
+ - Authorized creator and post resource methods
11
+ - Platform-specific creator ID and username selectors
12
+
5
13
  ## [0.1.0] - 2026-06-25
6
14
 
7
15
  ### Added
data/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
  Official Ruby client for the **Socialstats Enterprise API**.
4
4
 
5
5
  RubyGems: https://rubygems.org/gems/socialstats-ruby-sdk
6
- API Documentation: https://docs.socialstats.com
6
+ API Documentation: https://developers.stats.company/socialstats<br>
7
7
  API Key Access: Please contact api@socialstats.com
8
8
 
9
9
  ---
@@ -59,6 +59,14 @@ Or install directly via RubyGems:
59
59
  post_id: "7654234001833610518"
60
60
  )
61
61
 
62
+ # Start and poll a creator authorization
63
+ authorization = client.oauth.create(
64
+ socialstats_creator_id: "d3rvjgk2",
65
+ source_id: "youtube",
66
+ return_url: "https://customer.example.com/socialstats/oauth-return"
67
+ )
68
+ authorization_status = client.oauth.attempt_status(authorization["state_token"])
69
+
62
70
  ---
63
71
 
64
72
  ## Authentication
@@ -78,10 +86,14 @@ We recommend storing your key securely in environment variables:
78
86
  - `client.info`
79
87
  - `client.creators`
80
88
  - `client.posts`
89
+ - `client.oauth`
90
+
91
+ Creator-scoped methods accept `socialstats_creator_id`, `instagram_creator_id`, `facebook_creator_id`, `youtube_creator_id`, or `tiktok_creator_id`. Platform-specific identifiers may be either the platform's internal ID or its username.
81
92
 
82
93
  Info endpoints:
83
94
  - `client.info.sources` -> `/sources`
84
95
  - `client.info.status` -> `/status`
96
+ - `client.info.uptime_check` -> `/uptime_check`
85
97
  - `client.info.definitions` -> `/definitions`
86
98
 
87
99
  Creator endpoints:
@@ -92,6 +104,10 @@ Creator endpoints:
92
104
  - `client.creators.audience_details(country_code: ..., ...)` -> `/creators/audience/details`
93
105
  - `client.creators.activities(...)` -> `/creators/activities`
94
106
  - `client.creators.content(...)` -> `/creators/content`
107
+ - `client.creators.authorized_stats(...)` -> `/creators/authorized/stats`
108
+ - `client.creators.authorized_historic_stats(...)` -> `/creators/authorized/historic_stats`
109
+ - `client.creators.authorized_audience(...)` -> `/creators/authorized/audience`
110
+ - `client.creators.authorized_content(...)` -> `/creators/authorized/content`
95
111
  - `client.creators.top_posts(...)` -> `/creators/top_posts`
96
112
  - `client.creators.search(q: ..., ...)` -> `/creators/search`
97
113
  - `client.creators.add_link_request(link: ..., ...)` -> `/creators/link_request`
@@ -100,6 +116,15 @@ Creator endpoints:
100
116
  Post endpoints:
101
117
  - `client.posts.stats(...)` -> `/posts/stats`
102
118
  - `client.posts.historic_stats(...)` -> `/posts/historic_stats`
119
+ - `client.posts.authorized_stats(...)` -> `/posts/authorized/{source_id}/stats`
120
+ - `client.posts.authorized_historic_stats(...)` -> `/posts/authorized/{source_id}/historic_stats`
121
+
122
+ OAuth endpoints:
123
+ - `client.oauth.create(...)` -> `POST /oauth`
124
+ - `client.oauth.list(...)` -> `GET /oauth`
125
+ - `client.oauth.get(...)` -> `GET /oauth/{id}`
126
+ - `client.oauth.revoke(...)` -> `DELETE /oauth/{id}`
127
+ - `client.oauth.attempt_status(...)` -> `GET /oauth-attempts/{state_token}`
103
128
 
104
129
  ---
105
130
 
@@ -30,14 +30,34 @@ Authentication observed in Rails: `apikey` request header.
30
30
  | GET | `/audience/details` | `client.creators.audience_details(country_code: ..., ...)` |
31
31
  | GET | `/activities` | `client.creators.activities(...)` |
32
32
  | GET | `/content` | `client.creators.content(...)` |
33
+ | GET | `/authorized/stats` | `client.creators.authorized_stats(...)` |
34
+ | GET | `/authorized/historic_stats` | `client.creators.authorized_historic_stats(...)` |
35
+ | GET | `/authorized/audience` | `client.creators.authorized_audience(...)` |
36
+ | GET | `/authorized/content` | `client.creators.authorized_content(...)` |
33
37
  | GET | `/top_posts` | `client.creators.top_posts(...)` |
34
38
  | GET | `/search` | `client.creators.search(q: ..., ...)` |
35
39
  | POST | `/link_request` | `client.creators.add_link_request(link: ..., ...)` |
36
40
  | DELETE | `/link_request` | `client.creators.remove_link_request(link: ..., ...)` |
37
41
 
42
+ Creator-scoped methods require one creator identifier: `socialstats_creator_id`, `instagram_creator_id`, `facebook_creator_id`, `youtube_creator_id`, or `tiktok_creator_id`.
43
+
38
44
  ## `/enterprise/v1/posts`
39
45
 
40
46
  | HTTP | Route | SDK Method |
41
47
  | ---- | ----------------- | ---------------------------------- |
42
48
  | GET | `/stats` | `client.posts.stats(...)` |
43
49
  | GET | `/historic_stats` | `client.posts.historic_stats(...)` |
50
+ | GET | `/authorized/:source_id/stats` | `client.posts.authorized_stats(...)` |
51
+ | GET | `/authorized/:source_id/historic_stats` | `client.posts.authorized_historic_stats(...)` |
52
+
53
+ Post methods require one creator identifier, `source_id`, and one of `post_id`, `id_unique`, or `external_id`.
54
+
55
+ ## `/enterprise/v1/oauth`
56
+
57
+ | HTTP | Route | SDK Method |
58
+ | ------ | ------------------------------ | ------------------------------------------- |
59
+ | POST | `/oauth` | `client.oauth.create(...)` |
60
+ | GET | `/oauth` | `client.oauth.list(...)` |
61
+ | GET | `/oauth/:id` | `client.oauth.get(id)` |
62
+ | DELETE | `/oauth/:id` | `client.oauth.revoke(id)` |
63
+ | GET | `/oauth-attempts/:state_token` | `client.oauth.attempt_status(state_token)` |
@@ -2,7 +2,7 @@
2
2
 
3
3
  module SocialstatsSDK
4
4
  class Client
5
- attr_reader :info, :creators, :posts
5
+ attr_reader :info, :creators, :posts, :oauth
6
6
 
7
7
  def initialize(api_key:, base_url: HTTPClient::DEFAULT_BASE_URL, timeout: HTTPClient::DEFAULT_TIMEOUT_SECONDS,
8
8
  max_retries: 2, http_adapter: nil, user_agent: nil)
@@ -18,6 +18,7 @@ module SocialstatsSDK
18
18
  @info = Resources::Info.new(@http)
19
19
  @creators = Resources::Creators.new(@http)
20
20
  @posts = Resources::Posts.new(@http)
21
+ @oauth = Resources::OAuth.new(@http)
21
22
  end
22
23
 
23
24
  def close
@@ -3,6 +3,14 @@
3
3
  module SocialstatsSDK
4
4
  module Resources
5
5
  class Base
6
+ CREATOR_IDENTIFIER_KEYS = %i[
7
+ socialstats_creator_id
8
+ instagram_creator_id
9
+ facebook_creator_id
10
+ youtube_creator_id
11
+ tiktok_creator_id
12
+ ].freeze
13
+
6
14
  def initialize(http_client)
7
15
  @http = http_client
8
16
  end
@@ -12,6 +20,7 @@ module SocialstatsSDK
12
20
  def get(path, params: nil)
13
21
  @http.request(:get, path, params: normalize_params(params))
14
22
  end
23
+ alias request_get get
15
24
 
16
25
  def post(path, params: nil, json: nil)
17
26
  @http.request(:post, path, params: normalize_params(params), json: normalize_params(json))
@@ -3,8 +3,6 @@
3
3
  module SocialstatsSDK
4
4
  module Resources
5
5
  class Creators < Base
6
- IDENTIFIER_KEYS = %i[socialstats_creator_id].freeze
7
-
8
6
  def info(**params)
9
7
  get("creators/info", params: with_identifier(params))
10
8
  end
@@ -37,6 +35,22 @@ module SocialstatsSDK
37
35
  get("creators/content", params: with_identifier(params))
38
36
  end
39
37
 
38
+ def authorized_stats(**params)
39
+ get("creators/authorized/stats", params: with_identifier(params))
40
+ end
41
+
42
+ def authorized_historic_stats(**params)
43
+ get("creators/authorized/historic_stats", params: with_identifier(params))
44
+ end
45
+
46
+ def authorized_audience(**params)
47
+ get("creators/authorized/audience", params: with_identifier(params))
48
+ end
49
+
50
+ def authorized_content(**params)
51
+ get("creators/authorized/content", params: with_identifier(params))
52
+ end
53
+
40
54
  def top_posts(**params)
41
55
  get("creators/top_posts", params: with_identifier(params))
42
56
  end
@@ -67,7 +81,7 @@ module SocialstatsSDK
67
81
 
68
82
  def with_identifier(params)
69
83
  query = params.dup
70
- require_any_identifier!(query, IDENTIFIER_KEYS)
84
+ require_any_identifier!(query, CREATOR_IDENTIFIER_KEYS)
71
85
  query
72
86
  end
73
87
  end
@@ -0,0 +1,45 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "uri"
4
+
5
+ module SocialstatsSDK
6
+ module Resources
7
+ class OAuth < Base
8
+ def create(source_id:, **params)
9
+ raise ArgumentError, "source_id is required" if source_id.to_s.empty?
10
+
11
+ query = params.merge(source_id: source_id)
12
+ require_any_identifier!(query, CREATOR_IDENTIFIER_KEYS)
13
+ post("oauth", params: query)
14
+ end
15
+
16
+ def list(**params)
17
+ request_get("oauth", params: params)
18
+ end
19
+
20
+ def get(authorization_id)
21
+ raise ArgumentError, "authorization_id is required" if authorization_id.to_s.empty?
22
+
23
+ request_get("oauth/#{escape(authorization_id)}")
24
+ end
25
+
26
+ def revoke(authorization_id)
27
+ raise ArgumentError, "authorization_id is required" if authorization_id.to_s.empty?
28
+
29
+ delete("oauth/#{escape(authorization_id)}")
30
+ end
31
+
32
+ def attempt_status(state_token)
33
+ raise ArgumentError, "state_token is required" if state_token.to_s.empty?
34
+
35
+ request_get("oauth-attempts/#{escape(state_token)}")
36
+ end
37
+
38
+ private
39
+
40
+ def escape(value)
41
+ URI.encode_uri_component(value.to_s)
42
+ end
43
+ end
44
+ end
45
+ end
@@ -1,9 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "uri"
4
+
3
5
  module SocialstatsSDK
4
6
  module Resources
5
7
  class Posts < Base
6
- CREATOR_IDENTIFIER_KEYS = %i[socialstats_creator_id].freeze
7
8
  POST_IDENTIFIER_KEYS = %i[post_id id_unique external_id].freeze
8
9
 
9
10
  def stats(source_id:, **params)
@@ -14,6 +15,16 @@ module SocialstatsSDK
14
15
  get("posts/historic_stats", params: with_post_identifier(params.merge(source_id: source_id)))
15
16
  end
16
17
 
18
+ def authorized_stats(source_id:, **params)
19
+ query = with_post_identifier(params.merge(source_id: source_id))
20
+ get("posts/authorized/#{URI.encode_uri_component(source_id.to_s)}/stats", params: query)
21
+ end
22
+
23
+ def authorized_historic_stats(source_id:, **params)
24
+ query = with_post_identifier(params.merge(source_id: source_id))
25
+ get("posts/authorized/#{URI.encode_uri_component(source_id.to_s)}/historic_stats", params: query)
26
+ end
27
+
17
28
  private
18
29
 
19
30
  def with_post_identifier(params)
@@ -4,3 +4,4 @@ require_relative "resources/base"
4
4
  require_relative "resources/info"
5
5
  require_relative "resources/creators"
6
6
  require_relative "resources/posts"
7
+ require_relative "resources/oauth"
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SocialstatsSDK
4
- VERSION = "0.1.0"
4
+ VERSION = "0.2.0"
5
5
  end
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: socialstats-ruby-sdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Songstats
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2026-06-25 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: activesupport
@@ -49,6 +48,7 @@ files:
49
48
  - lib/socialstats_sdk/resources/base.rb
50
49
  - lib/socialstats_sdk/resources/creators.rb
51
50
  - lib/socialstats_sdk/resources/info.rb
51
+ - lib/socialstats_sdk/resources/oauth.rb
52
52
  - lib/socialstats_sdk/resources/posts.rb
53
53
  - lib/socialstats_sdk/version.rb
54
54
  homepage: https://socialstats.com
@@ -60,7 +60,6 @@ metadata:
60
60
  bug_tracker_uri: https://github.com/songstats/socialstats-ruby-sdk/issues
61
61
  allowed_push_host: https://rubygems.org
62
62
  rubygems_mfa_required: 'true'
63
- post_install_message:
64
63
  rdoc_options: []
65
64
  require_paths:
66
65
  - lib
@@ -75,8 +74,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
75
74
  - !ruby/object:Gem::Version
76
75
  version: '0'
77
76
  requirements: []
78
- rubygems_version: 3.5.17
79
- signing_key:
77
+ rubygems_version: 4.0.16
80
78
  specification_version: 4
81
79
  summary: Ruby SDK for the Socialstats Enterprise API.
82
80
  test_files: []