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,69 @@
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 communities client for the X API v2.
11
+ class CommunitiesClient
12
+ def initialize(client)
13
+ @client = client
14
+ end
15
+
16
+ # Get Community by ID
17
+ def get_by_id(id:, community_fields: nil)
18
+ path = +"/2/communities/{id}"
19
+ path.gsub!("{id}", URI.encode_www_form_component(id.to_s))
20
+
21
+ query = {}
22
+ unless community_fields.nil?
23
+ query["community.fields"] = community_fields.is_a?(Array) ? community_fields.map(&:to_s).join(",") : community_fields.to_s
24
+ end
25
+
26
+ headers = {}
27
+ @client.execute_request(
28
+ method: "GET",
29
+ path: path,
30
+ schemes: ["BearerToken", "OAuth2UserToken", "UserToken"],
31
+ query: query,
32
+ headers: headers,
33
+ binary_response: false
34
+ )
35
+ end
36
+
37
+ # Search Communities
38
+ def search(query:, max_results: nil, next_token: nil, pagination_token: nil, community_fields: nil, &block)
39
+ path = +"/2/communities/search"
40
+
41
+ query = {}
42
+ unless query.nil?
43
+ query["query"] = query.to_s
44
+ end
45
+ unless max_results.nil?
46
+ query["max_results"] = max_results.to_s
47
+ end
48
+ unless next_token.nil?
49
+ query["next_token"] = next_token.to_s
50
+ end
51
+ unless community_fields.nil?
52
+ query["community.fields"] = community_fields.is_a?(Array) ? community_fields.map(&:to_s).join(",") : community_fields.to_s
53
+ end
54
+
55
+ headers = {}
56
+ enum = @client.execute_paginated(
57
+ method: "GET",
58
+ path: path,
59
+ schemes: ["OAuth2UserToken", "UserToken"],
60
+ pagination_param: "pagination_token",
61
+ initial_token: pagination_token,
62
+ base_query: query,
63
+ headers: headers
64
+ )
65
+ block ? enum.each(&block) : enum
66
+ end
67
+ end
68
+ end
69
+ end
@@ -0,0 +1,147 @@
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 community notes client for the X API v2.
11
+ class CommunityNotesClient
12
+ def initialize(client)
13
+ @client = client
14
+ end
15
+
16
+ # Evaluate a Community Note
17
+ def evaluate(body:)
18
+ path = +"/2/notes/evaluate"
19
+
20
+ query = {}
21
+
22
+ headers = {}
23
+ @client.execute_request(
24
+ method: "POST",
25
+ path: path,
26
+ schemes: ["OAuth2UserToken", "UserToken"],
27
+ query: query,
28
+ headers: headers,
29
+ body: body,
30
+ binary_request: false,
31
+ binary_response: false
32
+ )
33
+ end
34
+
35
+ # Create a Community Note
36
+ def create(body:)
37
+ path = +"/2/notes"
38
+
39
+ query = {}
40
+
41
+ headers = {}
42
+ @client.execute_request(
43
+ method: "POST",
44
+ path: path,
45
+ schemes: ["OAuth2UserToken", "UserToken"],
46
+ query: query,
47
+ headers: headers,
48
+ body: body,
49
+ binary_request: false,
50
+ binary_response: false
51
+ )
52
+ end
53
+
54
+ # Delete a Community Note
55
+ def delete(id:)
56
+ path = +"/2/notes/{id}"
57
+ path.gsub!("{id}", URI.encode_www_form_component(id.to_s))
58
+
59
+ query = {}
60
+
61
+ headers = {}
62
+ @client.execute_request(
63
+ method: "DELETE",
64
+ path: path,
65
+ schemes: ["OAuth2UserToken", "UserToken"],
66
+ query: query,
67
+ headers: headers,
68
+ binary_response: false
69
+ )
70
+ end
71
+
72
+ # Search for Posts Eligible for Community Notes
73
+ def search_eligible_posts(test_mode:, max_results: nil, pagination_token: nil, post_selection: nil, post_fields: nil, expansions: nil, user_fields: nil, media_fields: nil, poll_fields: nil, place_fields: nil, &block)
74
+ path = +"/2/notes/search/posts_eligible_for_notes"
75
+
76
+ query = {}
77
+ unless test_mode.nil?
78
+ query["test_mode"] = test_mode.to_s.downcase
79
+ end
80
+ unless max_results.nil?
81
+ query["max_results"] = max_results.to_s
82
+ end
83
+ unless post_selection.nil?
84
+ query["post_selection"] = post_selection.to_s
85
+ end
86
+ unless post_fields.nil?
87
+ query["post.fields"] = post_fields.is_a?(Array) ? post_fields.map(&:to_s).join(",") : post_fields.to_s
88
+ end
89
+ unless expansions.nil?
90
+ query["expansions"] = expansions.is_a?(Array) ? expansions.map(&:to_s).join(",") : expansions.to_s
91
+ end
92
+ unless user_fields.nil?
93
+ query["user.fields"] = user_fields.is_a?(Array) ? user_fields.map(&:to_s).join(",") : user_fields.to_s
94
+ end
95
+ unless media_fields.nil?
96
+ query["media.fields"] = media_fields.is_a?(Array) ? media_fields.map(&:to_s).join(",") : media_fields.to_s
97
+ end
98
+ unless poll_fields.nil?
99
+ query["poll.fields"] = poll_fields.is_a?(Array) ? poll_fields.map(&:to_s).join(",") : poll_fields.to_s
100
+ end
101
+ unless place_fields.nil?
102
+ query["place.fields"] = place_fields.is_a?(Array) ? place_fields.map(&:to_s).join(",") : place_fields.to_s
103
+ end
104
+
105
+ headers = {}
106
+ enum = @client.execute_paginated(
107
+ method: "GET",
108
+ path: path,
109
+ schemes: ["OAuth2UserToken", "UserToken"],
110
+ pagination_param: "pagination_token",
111
+ initial_token: pagination_token,
112
+ base_query: query,
113
+ headers: headers
114
+ )
115
+ block ? enum.each(&block) : enum
116
+ end
117
+
118
+ # Search for Community Notes Written
119
+ def search_written(test_mode:, max_results: nil, pagination_token: nil, note_fields: nil, &block)
120
+ path = +"/2/notes/search/notes_written"
121
+
122
+ query = {}
123
+ unless test_mode.nil?
124
+ query["test_mode"] = test_mode.to_s.downcase
125
+ end
126
+ unless max_results.nil?
127
+ query["max_results"] = max_results.to_s
128
+ end
129
+ unless note_fields.nil?
130
+ query["note.fields"] = note_fields.is_a?(Array) ? note_fields.map(&:to_s).join(",") : note_fields.to_s
131
+ end
132
+
133
+ headers = {}
134
+ enum = @client.execute_paginated(
135
+ method: "GET",
136
+ path: path,
137
+ schemes: ["OAuth2UserToken", "UserToken"],
138
+ pagination_param: "pagination_token",
139
+ initial_token: pagination_token,
140
+ base_query: query,
141
+ headers: headers
142
+ )
143
+ block ? enum.each(&block) : enum
144
+ end
145
+ end
146
+ end
147
+ end
@@ -0,0 +1,157 @@
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 compliance client for the X API v2.
11
+ class ComplianceClient
12
+ def initialize(client)
13
+ @client = client
14
+ end
15
+
16
+ # Get Compliance Jobs
17
+ def get_jobs(type:, status: nil, compliance_job_fields: nil)
18
+ path = +"/2/compliance/jobs"
19
+
20
+ query = {}
21
+ unless type.nil?
22
+ query["type"] = type.to_s
23
+ end
24
+ unless status.nil?
25
+ query["status"] = status.to_s
26
+ end
27
+ unless compliance_job_fields.nil?
28
+ query["compliance_job.fields"] = compliance_job_fields.is_a?(Array) ? compliance_job_fields.map(&:to_s).join(",") : compliance_job_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 Compliance Job
43
+ def create_jobs(body:, compliance_job_fields: nil)
44
+ path = +"/2/compliance/jobs"
45
+
46
+ query = {}
47
+ unless compliance_job_fields.nil?
48
+ query["compliance_job.fields"] = compliance_job_fields.is_a?(Array) ? compliance_job_fields.map(&:to_s).join(",") : compliance_job_fields.to_s
49
+ end
50
+
51
+ headers = {}
52
+ @client.execute_request(
53
+ method: "POST",
54
+ path: path,
55
+ schemes: ["BearerToken"],
56
+ query: query,
57
+ headers: headers,
58
+ body: body,
59
+ binary_request: false,
60
+ binary_response: false
61
+ )
62
+ end
63
+
64
+ # Download Compliance Job Results
65
+ def download_job_results(id:, token:, compliance_job_fields: nil)
66
+ path = +"/2/compliance/jobs/{id}/download"
67
+ path.gsub!("{id}", URI.encode_www_form_component(id.to_s))
68
+
69
+ query = {}
70
+ unless token.nil?
71
+ query["token"] = token.to_s
72
+ end
73
+ unless compliance_job_fields.nil?
74
+ query["compliance_job.fields"] = compliance_job_fields.is_a?(Array) ? compliance_job_fields.map(&:to_s).join(",") : compliance_job_fields.to_s
75
+ end
76
+
77
+ headers = {}
78
+ @client.execute_request(
79
+ method: "GET",
80
+ path: path,
81
+ schemes: ["BearerToken"],
82
+ query: query,
83
+ headers: headers,
84
+ binary_response: true
85
+ )
86
+ end
87
+
88
+ # Upload Compliance Job Submission
89
+ def upload_job_submission(id:, token:, body:, compliance_job_fields: nil)
90
+ path = +"/2/compliance/jobs/{id}/upload"
91
+ path.gsub!("{id}", URI.encode_www_form_component(id.to_s))
92
+
93
+ query = {}
94
+ unless token.nil?
95
+ query["token"] = token.to_s
96
+ end
97
+ unless compliance_job_fields.nil?
98
+ query["compliance_job.fields"] = compliance_job_fields.is_a?(Array) ? compliance_job_fields.map(&:to_s).join(",") : compliance_job_fields.to_s
99
+ end
100
+
101
+ headers = {}
102
+ @client.execute_request(
103
+ method: "PUT",
104
+ path: path,
105
+ schemes: ["BearerToken"],
106
+ query: query,
107
+ headers: headers,
108
+ body: body,
109
+ binary_request: true,
110
+ binary_response: false
111
+ )
112
+ end
113
+
114
+ # Get Compliance Job by ID
115
+ def get_jobs_by_id(id:, compliance_job_fields: nil)
116
+ path = +"/2/compliance/jobs/{id}"
117
+ path.gsub!("{id}", URI.encode_www_form_component(id.to_s))
118
+
119
+ query = {}
120
+ unless compliance_job_fields.nil?
121
+ query["compliance_job.fields"] = compliance_job_fields.is_a?(Array) ? compliance_job_fields.map(&:to_s).join(",") : compliance_job_fields.to_s
122
+ end
123
+
124
+ headers = {}
125
+ @client.execute_request(
126
+ method: "GET",
127
+ path: path,
128
+ schemes: ["BearerToken"],
129
+ query: query,
130
+ headers: headers,
131
+ binary_response: false
132
+ )
133
+ end
134
+
135
+ # Cancel Compliance Job
136
+ def delete_jobs_by_id(id:, compliance_job_fields: nil)
137
+ path = +"/2/compliance/jobs/{id}"
138
+ path.gsub!("{id}", URI.encode_www_form_component(id.to_s))
139
+
140
+ query = {}
141
+ unless compliance_job_fields.nil?
142
+ query["compliance_job.fields"] = compliance_job_fields.is_a?(Array) ? compliance_job_fields.map(&:to_s).join(",") : compliance_job_fields.to_s
143
+ end
144
+
145
+ headers = {}
146
+ @client.execute_request(
147
+ method: "DELETE",
148
+ path: path,
149
+ schemes: ["BearerToken"],
150
+ query: query,
151
+ headers: headers,
152
+ binary_response: false
153
+ )
154
+ end
155
+ end
156
+ end
157
+ end
@@ -0,0 +1,102 @@
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 connections client for the X API v2.
11
+ class ConnectionsClient
12
+ def initialize(client)
13
+ @client = client
14
+ end
15
+
16
+ # Terminate Connections by Endpoint
17
+ def delete_by_endpoint(endpoint_id:)
18
+ path = +"/2/connections/{endpoint_id}"
19
+ path.gsub!("{endpoint_id}", URI.encode_www_form_component(endpoint_id.to_s))
20
+
21
+ query = {}
22
+
23
+ headers = {}
24
+ @client.execute_request(
25
+ method: "DELETE",
26
+ path: path,
27
+ schemes: ["BearerToken"],
28
+ query: query,
29
+ headers: headers,
30
+ binary_response: false
31
+ )
32
+ end
33
+
34
+ # Get Connection History
35
+ def get_connection_history(status: nil, endpoints: nil, max_results: nil, pagination_token: nil, connection_fields: nil, &block)
36
+ path = +"/2/connections"
37
+
38
+ query = {}
39
+ unless status.nil?
40
+ query["status"] = status.to_s
41
+ end
42
+ unless endpoints.nil?
43
+ query["endpoints"] = endpoints.is_a?(Array) ? endpoints.map(&:to_s).join(",") : endpoints.to_s
44
+ end
45
+ unless max_results.nil?
46
+ query["max_results"] = max_results.to_s
47
+ end
48
+ unless connection_fields.nil?
49
+ query["connection.fields"] = connection_fields.is_a?(Array) ? connection_fields.map(&:to_s).join(",") : connection_fields.to_s
50
+ end
51
+
52
+ headers = {}
53
+ enum = @client.execute_paginated(
54
+ method: "GET",
55
+ path: path,
56
+ schemes: ["BearerToken"],
57
+ pagination_param: "pagination_token",
58
+ initial_token: pagination_token,
59
+ base_query: query,
60
+ headers: headers
61
+ )
62
+ block ? enum.each(&block) : enum
63
+ end
64
+
65
+ # Terminate Multiple Connections
66
+ def delete_by_uuids(body:)
67
+ path = +"/2/connections"
68
+
69
+ query = {}
70
+
71
+ headers = {}
72
+ @client.execute_request(
73
+ method: "DELETE",
74
+ path: path,
75
+ schemes: ["BearerToken"],
76
+ query: query,
77
+ headers: headers,
78
+ body: body,
79
+ binary_request: false,
80
+ binary_response: false
81
+ )
82
+ end
83
+
84
+ # Terminate All Connections
85
+ def delete_all()
86
+ path = +"/2/connections/all"
87
+
88
+ query = {}
89
+
90
+ headers = {}
91
+ @client.execute_request(
92
+ method: "DELETE",
93
+ path: path,
94
+ schemes: ["BearerToken"],
95
+ query: query,
96
+ headers: headers,
97
+ binary_response: false
98
+ )
99
+ end
100
+ end
101
+ end
102
+ end