nexus-invision 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.rubocop.yml +2 -0
- data/Gemfile +21 -0
- data/Gemfile.lock +110 -0
- data/README.md +55 -0
- data/Rakefile +4 -0
- data/lib/nexus/invision/client.rb +177 -0
- data/lib/nexus/invision/errors/bad_request.rb +24 -0
- data/lib/nexus/invision/errors/client_error.rb +23 -0
- data/lib/nexus/invision/errors/unexpected_response.rb +13 -0
- data/lib/nexus/invision/requests/add_member_to_secondary_group.rb +18 -0
- data/lib/nexus/invision/requests/create_forum_topic.rb +22 -0
- data/lib/nexus/invision/requests/create_member_warning.rb +22 -0
- data/lib/nexus/invision/requests/remove_member_from_secondary_group.rb +18 -0
- data/lib/nexus/invision/resources/login_link.rb +17 -0
- data/lib/nexus/invision/resources/topic.rb +17 -0
- data/lib/nexus/invision/resources/user.rb +17 -0
- data/lib/nexus/invision/resources/warning.rb +17 -0
- data/lib/nexus/invision/value_object.rb +28 -0
- data/lib/nexus/invision/version.rb +9 -0
- data/nexus-invision.gemspec +33 -0
- data/sorbet/config +4 -0
- data/sorbet/rbi/annotations/.gitattributes +1 -0
- data/sorbet/rbi/annotations/faraday.rbi +17 -0
- data/sorbet/rbi/annotations/rainbow.rbi +269 -0
- data/sorbet/rbi/gems/.gitattributes +1 -0
- data/sorbet/rbi/gems/ast@2.4.2.rbi +584 -0
- data/sorbet/rbi/gems/base64@0.1.1.rbi +172 -0
- data/sorbet/rbi/gems/diff-lcs@1.5.0.rbi +1083 -0
- data/sorbet/rbi/gems/erubi@1.12.0.rbi +145 -0
- data/sorbet/rbi/gems/faraday-net_http@3.0.2.rbi +146 -0
- data/sorbet/rbi/gems/faraday@2.7.11.rbi +2903 -0
- data/sorbet/rbi/gems/json@2.6.3.rbi +1533 -0
- data/sorbet/rbi/gems/language_server-protocol@3.17.0.3.rbi +14237 -0
- data/sorbet/rbi/gems/netrc@0.11.0.rbi +158 -0
- data/sorbet/rbi/gems/parallel@1.23.0.rbi +273 -0
- data/sorbet/rbi/gems/parser@3.2.2.4.rbi +5451 -0
- data/sorbet/rbi/gems/prettier_print@1.2.1.rbi +951 -0
- data/sorbet/rbi/gems/prism@0.15.1.rbi +23922 -0
- data/sorbet/rbi/gems/racc@1.7.1.rbi +161 -0
- data/sorbet/rbi/gems/rainbow@3.1.1.rbi +402 -0
- data/sorbet/rbi/gems/rake@13.1.0.rbi +3027 -0
- data/sorbet/rbi/gems/rbi@0.1.2.rbi +2922 -0
- data/sorbet/rbi/gems/regexp_parser@2.8.2.rbi +3749 -0
- data/sorbet/rbi/gems/rexml@3.2.6.rbi +4781 -0
- data/sorbet/rbi/gems/rspec-core@3.12.2.rbi +10910 -0
- data/sorbet/rbi/gems/rspec-expectations@3.12.3.rbi +8100 -0
- data/sorbet/rbi/gems/rspec-mocks@3.12.6.rbi +5310 -0
- data/sorbet/rbi/gems/rspec-support@3.12.1.rbi +1609 -0
- data/sorbet/rbi/gems/rspec@3.12.0.rbi +82 -0
- data/sorbet/rbi/gems/rubocop-ast@1.30.0.rbi +7003 -0
- data/sorbet/rbi/gems/rubocop-shopify@2.14.0.rbi +8 -0
- data/sorbet/rbi/gems/rubocop@1.57.2.rbi +56813 -0
- data/sorbet/rbi/gems/ruby-progressbar@1.13.0.rbi +1317 -0
- data/sorbet/rbi/gems/ruby2_keywords@0.0.5.rbi +8 -0
- data/sorbet/rbi/gems/spoom@1.2.4.rbi +3777 -0
- data/sorbet/rbi/gems/syntax_tree@6.2.0.rbi +23136 -0
- data/sorbet/rbi/gems/tapioca@0.11.9.rbi +3496 -0
- data/sorbet/rbi/gems/thor@1.3.0.rbi +4345 -0
- data/sorbet/rbi/gems/unicode-display_width@2.5.0.rbi +65 -0
- data/sorbet/rbi/gems/yard-sorbet@0.8.1.rbi +428 -0
- data/sorbet/rbi/gems/yard@0.9.34.rbi +18219 -0
- data/sorbet/rbi/todo.rbi +5 -0
- data/sorbet/tapioca/config.yml +13 -0
- data/sorbet/tapioca/require.rb +4 -0
- metadata +106 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 4b0350a4552d18c63a14afb7b050ce5601d30d925d61aed4a8c1d26a75c317d2
|
4
|
+
data.tar.gz: 8aa1f17d9fc4a5d0207fc2931b5de617c2f63b8dada69b262f1394a801d8af22
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 19446aee23a1c59eae6535d691cac9c094ea33b101b4e97556882815bbff707a8cb221e01bedd307b171911e4be287a4c723f8de7b1f16118974f1e3bb8c3875
|
7
|
+
data.tar.gz: 3477c056719ce9264016b6b09f3647c1d98f4b917056cfa86078ca8a4dfb6258030851a0ef6153e3301ea80dc2ee71b91a4769d8b3e3b54d94be06aba87e6820
|
data/.rubocop.yml
ADDED
data/Gemfile
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
source "https://rubygems.org"
|
4
|
+
|
5
|
+
# Specify your gem's dependencies in nexus-invision.gemspec
|
6
|
+
gemspec
|
7
|
+
|
8
|
+
gem "faraday", "~> 2.7"
|
9
|
+
gem "rake", "~> 13.0"
|
10
|
+
gem "sorbet-runtime"
|
11
|
+
|
12
|
+
group :development do
|
13
|
+
gem "rubocop", "~> 1.57"
|
14
|
+
gem "rubocop-shopify", "~> 2.14"
|
15
|
+
gem "sorbet"
|
16
|
+
gem "tapioca", require: false
|
17
|
+
end
|
18
|
+
|
19
|
+
group :test do
|
20
|
+
gem "rspec", "~> 3.12"
|
21
|
+
end
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,110 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
nexus-invision (0.0.0)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
ast (2.4.2)
|
10
|
+
base64 (0.1.1)
|
11
|
+
diff-lcs (1.5.0)
|
12
|
+
erubi (1.12.0)
|
13
|
+
faraday (2.7.11)
|
14
|
+
base64
|
15
|
+
faraday-net_http (>= 2.0, < 3.1)
|
16
|
+
ruby2_keywords (>= 0.0.4)
|
17
|
+
faraday-net_http (3.0.2)
|
18
|
+
json (2.6.3)
|
19
|
+
language_server-protocol (3.17.0.3)
|
20
|
+
netrc (0.11.0)
|
21
|
+
parallel (1.23.0)
|
22
|
+
parser (3.2.2.4)
|
23
|
+
ast (~> 2.4.1)
|
24
|
+
racc
|
25
|
+
prettier_print (1.2.1)
|
26
|
+
prism (0.15.1)
|
27
|
+
racc (1.7.1)
|
28
|
+
rainbow (3.1.1)
|
29
|
+
rake (13.1.0)
|
30
|
+
rbi (0.1.2)
|
31
|
+
prism (>= 0.15.1)
|
32
|
+
sorbet-runtime (>= 0.5.9204)
|
33
|
+
regexp_parser (2.8.2)
|
34
|
+
rexml (3.2.6)
|
35
|
+
rspec (3.12.0)
|
36
|
+
rspec-core (~> 3.12.0)
|
37
|
+
rspec-expectations (~> 3.12.0)
|
38
|
+
rspec-mocks (~> 3.12.0)
|
39
|
+
rspec-core (3.12.2)
|
40
|
+
rspec-support (~> 3.12.0)
|
41
|
+
rspec-expectations (3.12.3)
|
42
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
43
|
+
rspec-support (~> 3.12.0)
|
44
|
+
rspec-mocks (3.12.6)
|
45
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
46
|
+
rspec-support (~> 3.12.0)
|
47
|
+
rspec-support (3.12.1)
|
48
|
+
rubocop (1.57.2)
|
49
|
+
json (~> 2.3)
|
50
|
+
language_server-protocol (>= 3.17.0)
|
51
|
+
parallel (~> 1.10)
|
52
|
+
parser (>= 3.2.2.4)
|
53
|
+
rainbow (>= 2.2.2, < 4.0)
|
54
|
+
regexp_parser (>= 1.8, < 3.0)
|
55
|
+
rexml (>= 3.2.5, < 4.0)
|
56
|
+
rubocop-ast (>= 1.28.1, < 2.0)
|
57
|
+
ruby-progressbar (~> 1.7)
|
58
|
+
unicode-display_width (>= 2.4.0, < 3.0)
|
59
|
+
rubocop-ast (1.30.0)
|
60
|
+
parser (>= 3.2.1.0)
|
61
|
+
rubocop-shopify (2.14.0)
|
62
|
+
rubocop (~> 1.51)
|
63
|
+
ruby-progressbar (1.13.0)
|
64
|
+
ruby2_keywords (0.0.5)
|
65
|
+
sorbet (0.5.11108)
|
66
|
+
sorbet-static (= 0.5.11108)
|
67
|
+
sorbet-runtime (0.5.11108)
|
68
|
+
sorbet-static (0.5.11108-x86_64-linux)
|
69
|
+
sorbet-static-and-runtime (0.5.11108)
|
70
|
+
sorbet (= 0.5.11108)
|
71
|
+
sorbet-runtime (= 0.5.11108)
|
72
|
+
spoom (1.2.4)
|
73
|
+
erubi (>= 1.10.0)
|
74
|
+
sorbet-static-and-runtime (>= 0.5.10187)
|
75
|
+
syntax_tree (>= 6.1.1)
|
76
|
+
thor (>= 0.19.2)
|
77
|
+
syntax_tree (6.2.0)
|
78
|
+
prettier_print (>= 1.2.0)
|
79
|
+
tapioca (0.11.9)
|
80
|
+
bundler (>= 2.2.25)
|
81
|
+
netrc (>= 0.11.0)
|
82
|
+
parallel (>= 1.21.0)
|
83
|
+
rbi (~> 0.1.0, >= 0.1.0)
|
84
|
+
sorbet-static-and-runtime (>= 0.5.10187)
|
85
|
+
spoom (~> 1.2.0, >= 1.2.0)
|
86
|
+
thor (>= 1.2.0)
|
87
|
+
yard-sorbet
|
88
|
+
thor (1.3.0)
|
89
|
+
unicode-display_width (2.5.0)
|
90
|
+
yard (0.9.34)
|
91
|
+
yard-sorbet (0.8.1)
|
92
|
+
sorbet-runtime (>= 0.5)
|
93
|
+
yard (>= 0.9)
|
94
|
+
|
95
|
+
PLATFORMS
|
96
|
+
x86_64-linux
|
97
|
+
|
98
|
+
DEPENDENCIES
|
99
|
+
faraday (~> 2.7)
|
100
|
+
nexus-invision!
|
101
|
+
rake (~> 13.0)
|
102
|
+
rspec (~> 3.12)
|
103
|
+
rubocop (~> 1.57)
|
104
|
+
rubocop-shopify (~> 2.14)
|
105
|
+
sorbet
|
106
|
+
sorbet-runtime
|
107
|
+
tapioca
|
108
|
+
|
109
|
+
BUNDLED WITH
|
110
|
+
2.4.13
|
data/README.md
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
# Invision API
|
2
|
+
|
3
|
+
A client library for the Invision Community API.
|
4
|
+
|
5
|
+
## Release to rubygems
|
6
|
+
|
7
|
+
You must tag the commit to perform a release.
|
8
|
+
|
9
|
+
## Installation
|
10
|
+
|
11
|
+
Install the gem and add to the application's Gemfile by executing:
|
12
|
+
|
13
|
+
$ bundle add nexus-invision
|
14
|
+
|
15
|
+
If bundler is not being used to manage dependencies, install the gem by executing:
|
16
|
+
|
17
|
+
$ gem install nexus-invision
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
```ruby
|
22
|
+
require "nexus/invision/client"
|
23
|
+
|
24
|
+
client = Nexus::Invision::Client.build(base_url: "https://example.com/api", api_key: "secret")
|
25
|
+
|
26
|
+
request = Nexus::Invision::Requests::CreateForumTopic.new(
|
27
|
+
forum_id: 1,
|
28
|
+
title: "Hello World",
|
29
|
+
post: "This is my first post!"
|
30
|
+
)
|
31
|
+
|
32
|
+
begin
|
33
|
+
topic = client.create_forum_topic(request)
|
34
|
+
|
35
|
+
puts topic.id # 1337
|
36
|
+
rescue Nexus::Invision::Errors::BadRequest => e
|
37
|
+
# ...
|
38
|
+
rescue Nexus::Invision::Errors::UnexpectedResponse => e
|
39
|
+
# ...
|
40
|
+
end
|
41
|
+
```
|
42
|
+
|
43
|
+
## Development
|
44
|
+
|
45
|
+
After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
46
|
+
|
47
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
48
|
+
|
49
|
+
Run the test suite:
|
50
|
+
|
51
|
+
$ bundle exec rspec
|
52
|
+
|
53
|
+
## Contributing
|
54
|
+
|
55
|
+
Bug reports and pull requests are welcome on GitLab at https://gitlab.nexdev.uk/nexus-mods/public/nexus-invision
|
data/Rakefile
ADDED
@@ -0,0 +1,177 @@
|
|
1
|
+
# typed: strict
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require "faraday"
|
5
|
+
require "nexus/invision/errors/bad_request"
|
6
|
+
require "nexus/invision/errors/unexpected_response"
|
7
|
+
require "nexus/invision/requests/add_member_to_secondary_group"
|
8
|
+
require "nexus/invision/requests/create_forum_topic"
|
9
|
+
require "nexus/invision/requests/create_member_warning"
|
10
|
+
require "nexus/invision/requests/remove_member_from_secondary_group"
|
11
|
+
require "nexus/invision/resources/login_link"
|
12
|
+
require "nexus/invision/resources/topic"
|
13
|
+
require "nexus/invision/resources/user"
|
14
|
+
require "nexus/invision/resources/warning"
|
15
|
+
require "sorbet-runtime"
|
16
|
+
require "uri"
|
17
|
+
|
18
|
+
module Nexus
|
19
|
+
module Invision
|
20
|
+
class HTTPMethod < T::Enum
|
21
|
+
enums do
|
22
|
+
GET = new
|
23
|
+
POST = new
|
24
|
+
DELETE = new
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
class Client
|
29
|
+
extend T::Sig
|
30
|
+
|
31
|
+
sig { params(connection: Faraday::Connection).void }
|
32
|
+
def initialize(connection)
|
33
|
+
@connection = connection
|
34
|
+
end
|
35
|
+
|
36
|
+
class << self
|
37
|
+
extend T::Sig
|
38
|
+
|
39
|
+
sig do
|
40
|
+
params(
|
41
|
+
base_url: URI::HTTP,
|
42
|
+
api_key: String,
|
43
|
+
block: T.nilable(T.proc.params(arg0: Faraday::Connection).void),
|
44
|
+
).returns(Client)
|
45
|
+
end
|
46
|
+
def build(base_url:, api_key:, &block)
|
47
|
+
new(
|
48
|
+
Faraday.new(url: base_url.to_s, headers: { "Accept" => "application/json" }) do |builder|
|
49
|
+
builder.request(:authorization, :basic, api_key, "")
|
50
|
+
builder.request(:url_encoded)
|
51
|
+
builder.response(:json)
|
52
|
+
block&.call(builder)
|
53
|
+
end,
|
54
|
+
)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
sig { params(request: Requests::CreateForumTopic).returns(Resources::Topic) }
|
59
|
+
def create_forum_topic(request)
|
60
|
+
response = request(
|
61
|
+
http_method: HTTPMethod::POST,
|
62
|
+
endpoint: URI("forums/topics"),
|
63
|
+
params: request.serialize,
|
64
|
+
)
|
65
|
+
|
66
|
+
Resources::Topic.from_hash(response.body)
|
67
|
+
end
|
68
|
+
|
69
|
+
sig { params(nexusmods_member_id: Integer).returns(Resources::LoginLink) }
|
70
|
+
def login_link(nexusmods_member_id)
|
71
|
+
response = request(
|
72
|
+
http_method: HTTPMethod::GET,
|
73
|
+
endpoint: URI("core/loginlinks/#{nexusmods_member_id}"),
|
74
|
+
)
|
75
|
+
|
76
|
+
Resources::LoginLink.from_hash(response.body)
|
77
|
+
end
|
78
|
+
|
79
|
+
sig { params(request: Requests::AddMemberToSecondaryGroup).returns(Resources::User) }
|
80
|
+
def add_member_to_secondary_group(request)
|
81
|
+
response = request(
|
82
|
+
http_method: HTTPMethod::POST,
|
83
|
+
endpoint: URI("core/members/#{request.member_id}/secgroups/#{request.group_id}"),
|
84
|
+
)
|
85
|
+
|
86
|
+
Resources::User.from_hash(response.body)
|
87
|
+
end
|
88
|
+
|
89
|
+
sig { params(request: Requests::RemoveMemberFromSecondaryGroup).returns(Resources::User) }
|
90
|
+
def remove_member_from_secondary_group(request)
|
91
|
+
response = request(
|
92
|
+
http_method: HTTPMethod::DELETE,
|
93
|
+
endpoint: URI("core/members/#{request.member_id}/secgroups/#{request.group_id}"),
|
94
|
+
)
|
95
|
+
|
96
|
+
Resources::User.from_hash(response.body)
|
97
|
+
end
|
98
|
+
|
99
|
+
sig { params(request: Requests::CreateMemberWarning).returns(Resources::Warning) }
|
100
|
+
def create_member_warning(request)
|
101
|
+
response = request(
|
102
|
+
http_method: HTTPMethod::POST,
|
103
|
+
endpoint: URI("core/members/#{request.member_id}/warnings"),
|
104
|
+
params: request.serialize.except("member_id"),
|
105
|
+
)
|
106
|
+
|
107
|
+
Resources::Warning.from_hash(response.body)
|
108
|
+
end
|
109
|
+
|
110
|
+
sig { params(member_id: Integer).returns(Resources::User) }
|
111
|
+
def ban_member(member_id)
|
112
|
+
response = request(
|
113
|
+
http_method: HTTPMethod::POST,
|
114
|
+
endpoint: URI("core/bans/#{member_id}"),
|
115
|
+
)
|
116
|
+
|
117
|
+
Resources::User.from_hash(response.body)
|
118
|
+
end
|
119
|
+
|
120
|
+
sig { params(member_id: Integer).returns(Resources::User) }
|
121
|
+
def unban_member(member_id)
|
122
|
+
response = request(
|
123
|
+
http_method: HTTPMethod::DELETE,
|
124
|
+
endpoint: URI("core/bans/#{member_id}"),
|
125
|
+
)
|
126
|
+
|
127
|
+
Resources::User.from_hash(response.body)
|
128
|
+
end
|
129
|
+
|
130
|
+
private
|
131
|
+
|
132
|
+
sig do
|
133
|
+
params(
|
134
|
+
http_method: HTTPMethod,
|
135
|
+
endpoint: URI,
|
136
|
+
params: T::Hash[String, T.untyped],
|
137
|
+
).returns(Faraday::Response)
|
138
|
+
end
|
139
|
+
def request(http_method:, endpoint:, params: {})
|
140
|
+
response =
|
141
|
+
case http_method
|
142
|
+
when HTTPMethod::GET
|
143
|
+
@connection.get(endpoint, params)
|
144
|
+
when HTTPMethod::POST
|
145
|
+
@connection.post(endpoint, params)
|
146
|
+
when HTTPMethod::DELETE
|
147
|
+
@connection.delete(endpoint, params)
|
148
|
+
else
|
149
|
+
T.absurd(http_method)
|
150
|
+
end
|
151
|
+
|
152
|
+
handle_error(response) unless response.success?
|
153
|
+
|
154
|
+
response
|
155
|
+
end
|
156
|
+
|
157
|
+
ERROR_CODE_KEY = "errorCode"
|
158
|
+
ERROR_MESSAGE_KEY = "errorMessage"
|
159
|
+
|
160
|
+
sig { params(response: Faraday::Response).void }
|
161
|
+
def handle_error(response)
|
162
|
+
body = response.body
|
163
|
+
|
164
|
+
if bad_request_error?(body)
|
165
|
+
raise Errors::BadRequest.new(body[ERROR_MESSAGE_KEY], body[ERROR_CODE_KEY], response.env)
|
166
|
+
end
|
167
|
+
|
168
|
+
raise Errors::UnexpectedResponse.new("Unexpected response", response.env)
|
169
|
+
end
|
170
|
+
|
171
|
+
sig { params(body: Object).returns(T::Boolean) }
|
172
|
+
def bad_request_error?(body)
|
173
|
+
body.is_a?(Hash) && body.key?(ERROR_MESSAGE_KEY) && body.key?(ERROR_CODE_KEY)
|
174
|
+
end
|
175
|
+
end
|
176
|
+
end
|
177
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# typed: strict
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require "nexus/invision/errors/client_error"
|
5
|
+
require "sorbet-runtime"
|
6
|
+
|
7
|
+
module Nexus
|
8
|
+
module Invision
|
9
|
+
module Errors
|
10
|
+
class BadRequest < ClientError
|
11
|
+
extend T::Sig
|
12
|
+
|
13
|
+
sig { returns(String) }
|
14
|
+
attr_reader :code
|
15
|
+
|
16
|
+
sig { params(message: String, code: String, env: Faraday::Env).void }
|
17
|
+
def initialize(message, code, env)
|
18
|
+
super(message, env)
|
19
|
+
@code = code
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# typed: strict
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require "sorbet-runtime"
|
5
|
+
|
6
|
+
module Nexus
|
7
|
+
module Invision
|
8
|
+
module Errors
|
9
|
+
class ClientError < StandardError
|
10
|
+
extend T::Sig
|
11
|
+
|
12
|
+
sig { returns(Faraday::Env) }
|
13
|
+
attr_reader :env
|
14
|
+
|
15
|
+
sig { params(message: String, env: Faraday::Env).void }
|
16
|
+
def initialize(message, env)
|
17
|
+
super(message)
|
18
|
+
@env = env
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# typed: strict
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require "nexus/invision/value_object"
|
5
|
+
require "sorbet-runtime"
|
6
|
+
|
7
|
+
module Nexus
|
8
|
+
module Invision
|
9
|
+
module Requests
|
10
|
+
class AddMemberToSecondaryGroup < T::Struct
|
11
|
+
include ValueObject
|
12
|
+
|
13
|
+
const :member_id, Integer
|
14
|
+
const :group_id, Integer
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# typed: strict
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require "nexus/invision/value_object"
|
5
|
+
require "sorbet-runtime"
|
6
|
+
|
7
|
+
module Nexus
|
8
|
+
module Invision
|
9
|
+
module Requests
|
10
|
+
class CreateForumTopic < T::Struct
|
11
|
+
include ValueObject
|
12
|
+
|
13
|
+
const :forum_id, Integer
|
14
|
+
const :title, String
|
15
|
+
const :post, String
|
16
|
+
const :author, T.nilable(Integer)
|
17
|
+
const :close_time, T.nilable(Time)
|
18
|
+
const :prefix, T.nilable(String)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# typed: strict
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require "nexus/invision/value_object"
|
5
|
+
require "sorbet-runtime"
|
6
|
+
|
7
|
+
module Nexus
|
8
|
+
module Invision
|
9
|
+
module Requests
|
10
|
+
class CreateMemberWarning < T::Struct
|
11
|
+
include ValueObject
|
12
|
+
|
13
|
+
const :member_id, Integer
|
14
|
+
const :moderator, T.nilable(Integer)
|
15
|
+
const :reason, T.nilable(Integer)
|
16
|
+
const :acknowledged, T.nilable(T::Boolean)
|
17
|
+
const :suspend, T.nilable(T.any(Time, Integer))
|
18
|
+
const :member_note, T.nilable(String), name: "memberNote"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# typed: strict
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require "nexus/invision/value_object"
|
5
|
+
require "sorbet-runtime"
|
6
|
+
|
7
|
+
module Nexus
|
8
|
+
module Invision
|
9
|
+
module Requests
|
10
|
+
class RemoveMemberFromSecondaryGroup < T::Struct
|
11
|
+
include ValueObject
|
12
|
+
|
13
|
+
const :member_id, Integer
|
14
|
+
const :group_id, Integer
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# typed: strict
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require "nexus/invision/value_object"
|
5
|
+
require "sorbet-runtime"
|
6
|
+
|
7
|
+
module Nexus
|
8
|
+
module Invision
|
9
|
+
module Resources
|
10
|
+
class LoginLink < T::Struct
|
11
|
+
include ValueObject
|
12
|
+
|
13
|
+
const :id, Integer
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# typed: strict
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require "nexus/invision/value_object"
|
5
|
+
require "sorbet-runtime"
|
6
|
+
|
7
|
+
module Nexus
|
8
|
+
module Invision
|
9
|
+
module Resources
|
10
|
+
class Topic < T::Struct
|
11
|
+
include ValueObject
|
12
|
+
|
13
|
+
const :id, Integer
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# typed: strict
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require "nexus/invision/value_object"
|
5
|
+
require "sorbet-runtime"
|
6
|
+
|
7
|
+
module Nexus
|
8
|
+
module Invision
|
9
|
+
module Resources
|
10
|
+
class User < T::Struct
|
11
|
+
include ValueObject
|
12
|
+
|
13
|
+
const :id, Integer
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# typed: strict
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require "nexus/invision/value_object"
|
5
|
+
require "sorbet-runtime"
|
6
|
+
|
7
|
+
module Nexus
|
8
|
+
module Invision
|
9
|
+
module Resources
|
10
|
+
class Warning < T::Struct
|
11
|
+
include ValueObject
|
12
|
+
|
13
|
+
const :id, Integer
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# typed: strict
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require "sorbet-runtime"
|
5
|
+
|
6
|
+
module Nexus
|
7
|
+
module Invision
|
8
|
+
module ValueObject
|
9
|
+
extend T::Sig
|
10
|
+
extend T::Helpers
|
11
|
+
|
12
|
+
abstract!
|
13
|
+
|
14
|
+
sig { abstract.returns(T::Class[ValueObject]) }
|
15
|
+
def class; end
|
16
|
+
|
17
|
+
sig { abstract.returns(T::Hash[String, T.untyped]) }
|
18
|
+
def serialize; end
|
19
|
+
|
20
|
+
sig { params(other: ValueObject).returns(T::Boolean) }
|
21
|
+
def eql?(other)
|
22
|
+
self.class == other.class && serialize == other.serialize
|
23
|
+
end
|
24
|
+
|
25
|
+
alias_method :==, :eql?
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "lib/nexus/invision/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "nexus-invision"
|
7
|
+
spec.version = Nexus::Invision::VERSION
|
8
|
+
spec.authors = ["Jack Robertson"]
|
9
|
+
spec.email = ["jack.robertson@nexusmods.com"]
|
10
|
+
|
11
|
+
spec.summary = "A client for the Invision Community REST API."
|
12
|
+
spec.homepage = "https://gitlab.nexdev.uk/nexus-mods/public/nexus-invision"
|
13
|
+
spec.required_ruby_version = ">= 2.6.0"
|
14
|
+
|
15
|
+
# Specify which files should be added to the gem when it is released.
|
16
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
17
|
+
spec.files = Dir.chdir(__dir__) do
|
18
|
+
%x(git ls-files -z).split("\x0").reject do |f|
|
19
|
+
(File.expand_path(f) == __FILE__) || f.start_with?(
|
20
|
+
"bin/",
|
21
|
+
"test/",
|
22
|
+
"spec/",
|
23
|
+
"features/",
|
24
|
+
".git",
|
25
|
+
".circleci",
|
26
|
+
"appveyor",
|
27
|
+
)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
spec.bindir = "exe"
|
31
|
+
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
32
|
+
spec.require_paths = ["lib"]
|
33
|
+
end
|
data/sorbet/config
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
**/*.rbi linguist-vendored=true
|