xdk 0.1.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.
Files changed (37) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +21 -0
  3. data/README.md +123 -0
  4. data/lib/xdk/client.rb +410 -0
  5. data/lib/xdk/clients/account_activity_client.rb +109 -0
  6. data/lib/xdk/clients/account_client.rb +53 -0
  7. data/lib/xdk/clients/activity_client.rb +119 -0
  8. data/lib/xdk/clients/articles_client.rb +54 -0
  9. data/lib/xdk/clients/bots_client.rb +138 -0
  10. data/lib/xdk/clients/broadcasts_client.rb +854 -0
  11. data/lib/xdk/clients/calls_client.rb +255 -0
  12. data/lib/xdk/clients/chat_client.rb +1017 -0
  13. data/lib/xdk/clients/communities_client.rb +69 -0
  14. data/lib/xdk/clients/community_notes_client.rb +147 -0
  15. data/lib/xdk/clients/compliance_client.rb +157 -0
  16. data/lib/xdk/clients/connections_client.rb +102 -0
  17. data/lib/xdk/clients/direct_messages_client.rb +269 -0
  18. data/lib/xdk/clients/general_client.rb +34 -0
  19. data/lib/xdk/clients/lists_client.rb +245 -0
  20. data/lib/xdk/clients/media_client.rb +400 -0
  21. data/lib/xdk/clients/news_client.rb +67 -0
  22. data/lib/xdk/clients/posts_client.rb +596 -0
  23. data/lib/xdk/clients/spaces_client.rb +222 -0
  24. data/lib/xdk/clients/stream_client.rb +690 -0
  25. data/lib/xdk/clients/trends_client.rb +81 -0
  26. data/lib/xdk/clients/usage_client.rb +57 -0
  27. data/lib/xdk/clients/users_client.rb +1280 -0
  28. data/lib/xdk/clients/webhooks_client.rb +164 -0
  29. data/lib/xdk/errors.rb +69 -0
  30. data/lib/xdk/http_client.rb +126 -0
  31. data/lib/xdk/oauth1.rb +183 -0
  32. data/lib/xdk/oauth2_pkce.rb +156 -0
  33. data/lib/xdk/paginator.rb +41 -0
  34. data/lib/xdk/streaming.rb +294 -0
  35. data/lib/xdk/version.rb +9 -0
  36. data/lib/xdk.rb +62 -0
  37. metadata +84 -0
@@ -0,0 +1,81 @@
1
+ # AUTO-GENERATED FILE - DO NOT EDIT
2
+ # This file was automatically generated by the XDK build tool.
3
+ # Any manual changes will be overwritten on the next generation.
4
+ # frozen_string_literal: true
5
+
6
+ require "uri"
7
+
8
+ module Xdk
9
+ module Clients
10
+ # Auto-generated trends client for the X API v2.
11
+ class TrendsClient
12
+ def initialize(client)
13
+ @client = client
14
+ end
15
+
16
+ # Get Trend Locations
17
+ def get_locations(trend_location_fields: nil)
18
+ path = +"/2/trends/locations"
19
+
20
+ query = {}
21
+ unless trend_location_fields.nil?
22
+ query["trend_location.fields"] = trend_location_fields.is_a?(Array) ? trend_location_fields.map(&:to_s).join(",") : trend_location_fields.to_s
23
+ end
24
+
25
+ headers = {}
26
+ @client.execute_request(
27
+ method: "GET",
28
+ path: path,
29
+ schemes: ["BearerToken", "OAuth2UserToken"],
30
+ query: query,
31
+ headers: headers,
32
+ binary_response: false
33
+ )
34
+ end
35
+
36
+ # Get Trends by WOEID
37
+ def get_by_woeid(woeid:, max_trends: nil, trend_fields: nil)
38
+ path = +"/2/trends/by/woeid/{woeid}"
39
+ path.gsub!("{woeid}", URI.encode_www_form_component(woeid.to_s))
40
+
41
+ query = {}
42
+ unless max_trends.nil?
43
+ query["max_trends"] = max_trends.to_s
44
+ end
45
+ unless trend_fields.nil?
46
+ query["trend.fields"] = trend_fields.is_a?(Array) ? trend_fields.map(&:to_s).join(",") : trend_fields.to_s
47
+ end
48
+
49
+ headers = {}
50
+ @client.execute_request(
51
+ method: "GET",
52
+ path: path,
53
+ schemes: ["BearerToken", "OAuth2UserToken"],
54
+ query: query,
55
+ headers: headers,
56
+ binary_response: false
57
+ )
58
+ end
59
+
60
+ # Get Personalized Trends
61
+ def get_personalized(personalized_trend_fields: nil)
62
+ path = +"/2/users/personalized_trends"
63
+
64
+ query = {}
65
+ unless personalized_trend_fields.nil?
66
+ query["personalized_trend.fields"] = personalized_trend_fields.is_a?(Array) ? personalized_trend_fields.map(&:to_s).join(",") : personalized_trend_fields.to_s
67
+ end
68
+
69
+ headers = {}
70
+ @client.execute_request(
71
+ method: "GET",
72
+ path: path,
73
+ schemes: ["OAuth2UserToken", "UserToken"],
74
+ query: query,
75
+ headers: headers,
76
+ binary_response: false
77
+ )
78
+ end
79
+ end
80
+ end
81
+ end
@@ -0,0 +1,57 @@
1
+ # AUTO-GENERATED FILE - DO NOT EDIT
2
+ # This file was automatically generated by the XDK build tool.
3
+ # Any manual changes will be overwritten on the next generation.
4
+ # frozen_string_literal: true
5
+
6
+ require "uri"
7
+
8
+ module Xdk
9
+ module Clients
10
+ # Auto-generated usage client for the X API v2.
11
+ class UsageClient
12
+ def initialize(client)
13
+ @client = client
14
+ end
15
+
16
+ # Get Usage Credits
17
+ def get_credits()
18
+ path = +"/2/usage/credits"
19
+
20
+ query = {}
21
+
22
+ headers = {}
23
+ @client.execute_request(
24
+ method: "GET",
25
+ path: path,
26
+ schemes: ["BearerToken", "OAuth2UserToken"],
27
+ query: query,
28
+ headers: headers,
29
+ binary_response: false
30
+ )
31
+ end
32
+
33
+ # Get Usage
34
+ def get(days: nil, usage_fields: nil)
35
+ path = +"/2/usage/tweets"
36
+
37
+ query = {}
38
+ unless days.nil?
39
+ query["days"] = days.to_s
40
+ end
41
+ unless usage_fields.nil?
42
+ query["usage.fields"] = usage_fields.is_a?(Array) ? usage_fields.map(&:to_s).join(",") : usage_fields.to_s
43
+ end
44
+
45
+ headers = {}
46
+ @client.execute_request(
47
+ method: "GET",
48
+ path: path,
49
+ schemes: ["BearerToken"],
50
+ query: query,
51
+ headers: headers,
52
+ binary_response: false
53
+ )
54
+ end
55
+ end
56
+ end
57
+ end