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,53 @@
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 account client for the X API v2.
11
+ class AccountClient
12
+ def initialize(client)
13
+ @client = client
14
+ end
15
+
16
+ # Get Developer Account
17
+ def get_developer()
18
+ path = +"/2/account"
19
+
20
+ query = {}
21
+
22
+ headers = {}
23
+ @client.execute_request(
24
+ method: "GET",
25
+ path: path,
26
+ schemes: ["OAuth2UserToken"],
27
+ query: query,
28
+ headers: headers,
29
+ binary_response: false
30
+ )
31
+ end
32
+
33
+ # Ensure Developer Account
34
+ def ensure_(body:)
35
+ path = +"/2/account"
36
+
37
+ query = {}
38
+
39
+ headers = {}
40
+ @client.execute_request(
41
+ method: "POST",
42
+ path: path,
43
+ schemes: ["OAuth2UserToken"],
44
+ query: query,
45
+ headers: headers,
46
+ body: body,
47
+ binary_request: false,
48
+ binary_response: false
49
+ )
50
+ end
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,119 @@
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 activity client for the X API v2.
11
+ class ActivityClient
12
+ def initialize(client)
13
+ @client = client
14
+ end
15
+
16
+ # Get X Activity Subscriptions
17
+ def get_subscriptions(max_results: nil, pagination_token: nil, user_id: nil, &block)
18
+ path = +"/2/activity/subscriptions"
19
+
20
+ query = {}
21
+ unless max_results.nil?
22
+ query["max_results"] = max_results.to_s
23
+ end
24
+ unless user_id.nil?
25
+ query["user_id"] = user_id.to_s
26
+ end
27
+
28
+ headers = {}
29
+ enum = @client.execute_paginated(
30
+ method: "GET",
31
+ path: path,
32
+ schemes: ["BearerToken", "OAuth2UserToken", "UserToken"],
33
+ pagination_param: "pagination_token",
34
+ initial_token: pagination_token,
35
+ base_query: query,
36
+ headers: headers
37
+ )
38
+ block ? enum.each(&block) : enum
39
+ end
40
+
41
+ # Create X Activity Subscription
42
+ def create_subscription(body:)
43
+ path = +"/2/activity/subscriptions"
44
+
45
+ query = {}
46
+
47
+ headers = {}
48
+ @client.execute_request(
49
+ method: "POST",
50
+ path: path,
51
+ schemes: ["BearerToken", "OAuth2UserToken", "UserToken"],
52
+ query: query,
53
+ headers: headers,
54
+ body: body,
55
+ binary_request: false,
56
+ binary_response: false
57
+ )
58
+ end
59
+
60
+ # Delete X Activity Subscriptions by IDs
61
+ def delete_subscriptions_by_ids(ids:)
62
+ path = +"/2/activity/subscriptions"
63
+
64
+ query = {}
65
+ unless ids.nil?
66
+ query["ids"] = ids.is_a?(Array) ? ids.map(&:to_s).join(",") : ids.to_s
67
+ end
68
+
69
+ headers = {}
70
+ @client.execute_request(
71
+ method: "DELETE",
72
+ path: path,
73
+ schemes: ["BearerToken"],
74
+ query: query,
75
+ headers: headers,
76
+ binary_response: false
77
+ )
78
+ end
79
+
80
+ # Update X Activity Subscription
81
+ def update_subscription(subscription_id:, body:)
82
+ path = +"/2/activity/subscriptions/{subscription_id}"
83
+ path.gsub!("{subscription_id}", URI.encode_www_form_component(subscription_id.to_s))
84
+
85
+ query = {}
86
+
87
+ headers = {}
88
+ @client.execute_request(
89
+ method: "PUT",
90
+ path: path,
91
+ schemes: ["BearerToken", "OAuth2UserToken", "UserToken"],
92
+ query: query,
93
+ headers: headers,
94
+ body: body,
95
+ binary_request: false,
96
+ binary_response: false
97
+ )
98
+ end
99
+
100
+ # Delete X Activity Subscription
101
+ def delete_subscription(subscription_id:)
102
+ path = +"/2/activity/subscriptions/{subscription_id}"
103
+ path.gsub!("{subscription_id}", URI.encode_www_form_component(subscription_id.to_s))
104
+
105
+ query = {}
106
+
107
+ headers = {}
108
+ @client.execute_request(
109
+ method: "DELETE",
110
+ path: path,
111
+ schemes: ["BearerToken", "OAuth2UserToken", "UserToken"],
112
+ query: query,
113
+ headers: headers,
114
+ binary_response: false
115
+ )
116
+ end
117
+ end
118
+ end
119
+ end
@@ -0,0 +1,54 @@
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 articles client for the X API v2.
11
+ class ArticlesClient
12
+ def initialize(client)
13
+ @client = client
14
+ end
15
+
16
+ # Publish Article
17
+ def article_publish(article_id:)
18
+ path = +"/2/articles/{article_id}/publish"
19
+ path.gsub!("{article_id}", URI.encode_www_form_component(article_id.to_s))
20
+
21
+ query = {}
22
+
23
+ headers = {}
24
+ @client.execute_request(
25
+ method: "POST",
26
+ path: path,
27
+ schemes: ["OAuth2UserToken", "UserToken"],
28
+ query: query,
29
+ headers: headers,
30
+ binary_response: false
31
+ )
32
+ end
33
+
34
+ # Create Draft Article
35
+ def article_create_draft(body:)
36
+ path = +"/2/articles/draft"
37
+
38
+ query = {}
39
+
40
+ headers = {}
41
+ @client.execute_request(
42
+ method: "POST",
43
+ path: path,
44
+ schemes: ["OAuth2UserToken", "UserToken"],
45
+ query: query,
46
+ headers: headers,
47
+ body: body,
48
+ binary_request: false,
49
+ binary_response: false
50
+ )
51
+ end
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,138 @@
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 bots client for the X API v2.
11
+ class BotsClient
12
+ def initialize(client)
13
+ @client = client
14
+ end
15
+
16
+ # Get Bots
17
+ def get(user_fields: nil, expansions: nil, post_fields: nil)
18
+ path = +"/2/bots"
19
+
20
+ query = {}
21
+ unless user_fields.nil?
22
+ query["user.fields"] = user_fields.is_a?(Array) ? user_fields.map(&:to_s).join(",") : user_fields.to_s
23
+ end
24
+ unless expansions.nil?
25
+ query["expansions"] = expansions.is_a?(Array) ? expansions.map(&:to_s).join(",") : expansions.to_s
26
+ end
27
+ unless post_fields.nil?
28
+ query["post.fields"] = post_fields.is_a?(Array) ? post_fields.map(&:to_s).join(",") : post_fields.to_s
29
+ end
30
+
31
+ headers = {}
32
+ @client.execute_request(
33
+ method: "GET",
34
+ path: path,
35
+ schemes: ["BearerToken"],
36
+ query: query,
37
+ headers: headers,
38
+ binary_response: false
39
+ )
40
+ end
41
+
42
+ # Create a Bot
43
+ def create_bot(body:)
44
+ path = +"/2/bots"
45
+
46
+ query = {}
47
+
48
+ headers = {}
49
+ @client.execute_request(
50
+ method: "POST",
51
+ path: path,
52
+ schemes: ["BearerToken", "OAuth2UserToken"],
53
+ query: query,
54
+ headers: headers,
55
+ body: body,
56
+ binary_request: false,
57
+ binary_response: false
58
+ )
59
+ end
60
+
61
+ # Rotate Bot Token
62
+ def rotate_bot_token(id:, body:)
63
+ path = +"/2/bots/{id}/token"
64
+ path.gsub!("{id}", URI.encode_www_form_component(id.to_s))
65
+
66
+ query = {}
67
+
68
+ headers = {}
69
+ @client.execute_request(
70
+ method: "POST",
71
+ path: path,
72
+ schemes: ["BearerToken", "OAuth2UserToken"],
73
+ query: query,
74
+ headers: headers,
75
+ body: body,
76
+ binary_request: false,
77
+ binary_response: false
78
+ )
79
+ end
80
+
81
+ # Revoke Bot Token
82
+ def revoke_bot_token(id:)
83
+ path = +"/2/bots/{id}/token"
84
+ path.gsub!("{id}", URI.encode_www_form_component(id.to_s))
85
+
86
+ query = {}
87
+
88
+ headers = {}
89
+ @client.execute_request(
90
+ method: "DELETE",
91
+ path: path,
92
+ schemes: ["BearerToken"],
93
+ query: query,
94
+ headers: headers,
95
+ binary_response: false
96
+ )
97
+ end
98
+
99
+ # Update Bot
100
+ def update_bot(id:, body:)
101
+ path = +"/2/bots/{id}"
102
+ path.gsub!("{id}", URI.encode_www_form_component(id.to_s))
103
+
104
+ query = {}
105
+
106
+ headers = {}
107
+ @client.execute_request(
108
+ method: "PUT",
109
+ path: path,
110
+ schemes: ["BearerToken"],
111
+ query: query,
112
+ headers: headers,
113
+ body: body,
114
+ binary_request: false,
115
+ binary_response: false
116
+ )
117
+ end
118
+
119
+ # Delete Bot
120
+ def delete_bot(id:)
121
+ path = +"/2/bots/{id}"
122
+ path.gsub!("{id}", URI.encode_www_form_component(id.to_s))
123
+
124
+ query = {}
125
+
126
+ headers = {}
127
+ @client.execute_request(
128
+ method: "DELETE",
129
+ path: path,
130
+ schemes: ["BearerToken", "OAuth2UserToken"],
131
+ query: query,
132
+ headers: headers,
133
+ binary_response: false
134
+ )
135
+ end
136
+ end
137
+ end
138
+ end