nexus-invision 1.10.0 → 1.10.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a46bc47e73117d8aded28e0384362d5d6a6713749b388c296aa25846cea3b377
4
- data.tar.gz: 0d9c2d3f30523f032d40dd3a8272cf0b6337377f8e32f1f50bf627a7425ffcc9
3
+ metadata.gz: 6fbcb3cb66d480ad35a8b1098b2304280ec7335904dfcfd23678354a1223138e
4
+ data.tar.gz: d79352c041faaf55387bf1a0dd2ba4beb81d6a524bfd88d133ce65faa86d239e
5
5
  SHA512:
6
- metadata.gz: d68fe5188416eb36310f6a3b0e4f7750c84a0182d54252981e7abf4f0799faa608128c4339c8dc78263d4e2c32fe439bbbe48051d970af49b73ba178a2348df6
7
- data.tar.gz: 4a51d3057f44a7a84e770ce554d7802a5da51e16e6934415da92d294909322a6c44cdaf5073bf50d8aa1ecda6aa1b8624200770ea4d619995c80125209f867eb
6
+ metadata.gz: af3dcb05992c5e2e16d1b7fa773fea94eef6b55ed7f747b86b1fe31cfb7f20c7a64868e9ec78663e8484931399c1188c4bb8477954eb59003958c43d3f84ae35
7
+ data.tar.gz: de36438d81f7b99a97c0c6b78dad40a1851bae56cd8dac25f27ca74e5dcd0bb14732c6404c1d00c710c059e8340490c4da4e895b150f72bc8f15b3e9e85bdb5f
data/Gemfile CHANGED
@@ -18,4 +18,5 @@ end
18
18
 
19
19
  group :test do
20
20
  gem "rspec", "~> 3.12"
21
+ gem "vcr"
21
22
  end
data/Gemfile.lock CHANGED
@@ -87,6 +87,7 @@ GEM
87
87
  yard-sorbet
88
88
  thor (1.3.0)
89
89
  unicode-display_width (2.5.0)
90
+ vcr (6.2.0)
90
91
  yard (0.9.34)
91
92
  yard-sorbet (0.8.1)
92
93
  sorbet-runtime (>= 0.5)
@@ -105,6 +106,7 @@ DEPENDENCIES
105
106
  sorbet
106
107
  sorbet-runtime
107
108
  tapioca
109
+ vcr
108
110
 
109
111
  BUNDLED WITH
110
112
  2.4.13
@@ -2,6 +2,9 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  require "faraday"
5
+ require "sorbet-runtime"
6
+ require "uri"
7
+
5
8
  require "nexus/invision/client_interface"
6
9
  require "nexus/invision/errors/bad_request"
7
10
  require "nexus/invision/errors/unexpected_response"
@@ -12,23 +15,27 @@ require "nexus/invision/requests/create_member_warning"
12
15
  require "nexus/invision/requests/create_message"
13
16
  require "nexus/invision/requests/delete_member"
14
17
  require "nexus/invision/requests/edit_member"
15
- require "nexus/invision/requests/list_forum_topics"
16
- require "nexus/invision/requests/remove_member_from_secondary_group"
17
18
  require "nexus/invision/requests/edit_member_primary_group"
18
19
  require "nexus/invision/requests/ensure_member"
20
+ require "nexus/invision/requests/list_forum_topics"
21
+ require "nexus/invision/requests/remove_member_from_secondary_group"
19
22
  require "nexus/invision/requests/unread_count"
23
+ require "nexus/invision/resources/ensure_member"
24
+ require "nexus/invision/resources/field"
25
+ require "nexus/invision/resources/field_group"
26
+ require "nexus/invision/resources/forum"
20
27
  require "nexus/invision/resources/group"
21
28
  require "nexus/invision/resources/login_link"
22
29
  require "nexus/invision/resources/member"
23
30
  require "nexus/invision/resources/page"
31
+ require "nexus/invision/resources/poll"
24
32
  require "nexus/invision/resources/post"
33
+ require "nexus/invision/resources/question"
34
+ require "nexus/invision/resources/rank"
25
35
  require "nexus/invision/resources/topic"
36
+ require "nexus/invision/resources/unread_count"
26
37
  require "nexus/invision/resources/user"
27
38
  require "nexus/invision/resources/warning"
28
- require "nexus/invision/resources/ensure_member"
29
- require "nexus/invision/resources/unread_count"
30
- require "sorbet-runtime"
31
- require "uri"
32
39
 
33
40
  module Nexus
34
41
  module Invision
@@ -96,7 +103,7 @@ module Nexus
96
103
  endpoint: URI("forums/posts/#{post_id}"),
97
104
  )
98
105
 
99
- Resources::Post.from_hash(response.body)
106
+ Resources::Post.from_response(response.body)
100
107
  end
101
108
 
102
109
  sig { override.params(request: Requests::ListForumTopics).returns(Resources::Page[Resources::Topic]) }
@@ -114,7 +121,9 @@ module Nexus
114
121
  per_page: body.fetch("perPage"),
115
122
  total_results: body.fetch("totalResults"),
116
123
  total_pages: body.fetch("totalPages"),
117
- results: body.fetch("results").map { |result| Resources::Topic.from_hash(result) },
124
+ results: body.fetch("results").map do |result|
125
+ Resources::Topic.from_response(result)
126
+ end,
118
127
  )
119
128
  end
120
129
 
@@ -126,7 +135,7 @@ module Nexus
126
135
  params: request.serialize,
127
136
  )
128
137
 
129
- Resources::Topic.from_hash(response.body)
138
+ Resources::Topic.from_response(response.body)
130
139
  end
131
140
 
132
141
  sig { override.params(request: Requests::CreateForumPost).returns(Resources::Post) }
@@ -137,7 +146,7 @@ module Nexus
137
146
  params: request.serialize,
138
147
  )
139
148
 
140
- Resources::Post.from_hash(response.body)
149
+ Resources::Post.from_response(response.body)
141
150
  end
142
151
 
143
152
  sig { override.params(nexusmods_member_id: Integer).returns(Resources::LoginLink) }
@@ -147,7 +156,7 @@ module Nexus
147
156
  endpoint: URI("core/loginlinks/#{nexusmods_member_id}"),
148
157
  )
149
158
 
150
- Resources::LoginLink.from_hash(response.body)
159
+ Resources::LoginLink.from_response(response.body)
151
160
  end
152
161
 
153
162
  sig { override.params(nexusmods_member_id: Integer).returns(Resources::Member) }
@@ -157,7 +166,7 @@ module Nexus
157
166
  endpoint: URI("core/members/#{nexusmods_member_id}"),
158
167
  )
159
168
 
160
- Resources::Member.from_hash(response.body)
169
+ Resources::Member.from_response(response.body)
161
170
  end
162
171
 
163
172
  sig { override.params(request: Requests::EnsureMember).returns(Resources::EnsureMember) }
@@ -168,7 +177,7 @@ module Nexus
168
177
  params: request.serialize.except("id"),
169
178
  )
170
179
 
171
- Resources::EnsureMember.from_hash(response.body)
180
+ Resources::EnsureMember.from_response(response.body)
172
181
  end
173
182
 
174
183
  sig { override.params(request: Requests::CreateMessage).void }
@@ -187,7 +196,7 @@ module Nexus
187
196
  endpoint: URI("core/unreadcount/#{request.id}"),
188
197
  )
189
198
 
190
- Resources::UnreadCount.from_hash(response.body)
199
+ Resources::UnreadCount.from_response(response.body)
191
200
  end
192
201
 
193
202
  sig { override.params(request: Requests::EditMemberPrimaryGroup).returns(Resources::Member) }
@@ -197,7 +206,7 @@ module Nexus
197
206
  endpoint: URI("core/members/#{request.member_id}"),
198
207
  params: request.serialize.except("member_id"),
199
208
  )
200
- Resources::Member.from_hash(response.body)
209
+ Resources::Member.from_response(response.body)
201
210
  end
202
211
 
203
212
  sig { override.params(request: Requests::AddMemberToSecondaryGroup).returns(Resources::User) }
@@ -207,7 +216,7 @@ module Nexus
207
216
  endpoint: URI("core/members/#{request.member_id}/secgroup/#{request.group_id}"),
208
217
  )
209
218
 
210
- Resources::User.from_hash(response.body)
219
+ Resources::User.from_response(response.body)
211
220
  end
212
221
 
213
222
  sig { override.params(request: Requests::RemoveMemberFromSecondaryGroup).returns(Resources::User) }
@@ -217,7 +226,7 @@ module Nexus
217
226
  endpoint: URI("core/members/#{request.member_id}/secgroup/#{request.group_id}"),
218
227
  )
219
228
 
220
- Resources::User.from_hash(response.body)
229
+ Resources::User.from_response(response.body)
221
230
  end
222
231
 
223
232
  sig { override.params(request: Requests::CreateMemberWarning).returns(Resources::Warning) }
@@ -228,7 +237,7 @@ module Nexus
228
237
  params: request.serialize.except("member_id"),
229
238
  )
230
239
 
231
- Resources::Warning.from_hash(response.body)
240
+ Resources::Warning.from_response(response.body)
232
241
  end
233
242
 
234
243
  sig { override.params(member_id: Integer).returns(Resources::User) }
@@ -238,7 +247,7 @@ module Nexus
238
247
  endpoint: URI("core/bans/#{member_id}"),
239
248
  )
240
249
 
241
- Resources::User.from_hash(response.body)
250
+ Resources::User.from_response(response.body)
242
251
  end
243
252
 
244
253
  sig { override.params(member_id: Integer).returns(Resources::User) }
@@ -248,7 +257,7 @@ module Nexus
248
257
  endpoint: URI("core/bans/#{member_id}"),
249
258
  )
250
259
 
251
- Resources::User.from_hash(response.body)
260
+ Resources::User.from_response(response.body)
252
261
  end
253
262
 
254
263
  sig { override.params(request: Requests::DeleteMember).void }
@@ -269,7 +278,7 @@ module Nexus
269
278
  endpoint: URI("core/members/#{request.member_id}"),
270
279
  params: request.serialize.except("member_id"),
271
280
  )
272
- Resources::User.from_hash(response.body)
281
+ Resources::User.from_response(response.body)
273
282
  end
274
283
 
275
284
  private
@@ -12,6 +12,18 @@ module Nexus
12
12
 
13
13
  const :id, Integer
14
14
  const :created, T::Boolean
15
+
16
+ class << self
17
+ extend T::Sig
18
+
19
+ sig { params(response: T::Hash[String, T.untyped]).returns(EnsureMember) }
20
+ def from_response(response)
21
+ EnsureMember.new(
22
+ id: response["id"],
23
+ created: response["created"],
24
+ )
25
+ end
26
+ end
15
27
  end
16
28
  end
17
29
  end
@@ -0,0 +1,31 @@
1
+ # typed: strict
2
+ # frozen_string_literal: true
3
+
4
+ require "sorbet-runtime"
5
+
6
+ require "nexus/invision/value_object"
7
+
8
+ module Nexus
9
+ module Invision
10
+ module Resources
11
+ class Field < T::Struct
12
+ include ValueObject
13
+
14
+ const :name, String
15
+ const :value, String
16
+
17
+ class << self
18
+ extend T::Sig
19
+
20
+ sig { params(response: T::Hash[String, T.untyped]).returns(Field) }
21
+ def from_response(response)
22
+ Field.new(
23
+ name: response["name"],
24
+ value: response["value"],
25
+ )
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,32 @@
1
+ # typed: strict
2
+ # frozen_string_literal: true
3
+
4
+ require "sorbet-runtime"
5
+
6
+ require "nexus/invision/value_object"
7
+ require "nexus/invision/resources/field"
8
+
9
+ module Nexus
10
+ module Invision
11
+ module Resources
12
+ class FieldGroup < T::Struct
13
+ include ValueObject
14
+
15
+ const :name, Integer
16
+ const :fields, T::Hash[String, Field]
17
+
18
+ class << self
19
+ extend T::Sig
20
+
21
+ sig { params(response: T::Hash[String, T.untyped]).returns(FieldGroup) }
22
+ def from_response(response)
23
+ FieldGroup.new(
24
+ name: response["name"],
25
+ fields: response["fields"].map { |f| Field.from_response(f) },
26
+ )
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,43 @@
1
+ # typed: strict
2
+ # frozen_string_literal: true
3
+
4
+ require "sorbet-runtime"
5
+
6
+ require "nexus/invision/value_object"
7
+
8
+ module Nexus
9
+ module Invision
10
+ module Resources
11
+ class Forum < T::Struct
12
+ include ValueObject
13
+
14
+ const :id, Integer
15
+ const :name, String
16
+ const :path, String
17
+ const :type, String
18
+ const :topics, Integer
19
+ const :url, String
20
+ const :parentId, T.nilable(Integer)
21
+ const :permissions, T.nilable(T::Hash[T.untyped, T.untyped])
22
+
23
+ class << self
24
+ extend T::Sig
25
+
26
+ sig { params(response: T::Hash[String, T.untyped]).returns(Forum) }
27
+ def from_response(response)
28
+ Forum.new(
29
+ id: response["id"],
30
+ name: response["name"],
31
+ path: response["path"],
32
+ type: response["type"],
33
+ topics: response["topics"],
34
+ url: response["url"],
35
+ parentId: response["parentId"],
36
+ permissions: response["permissions"],
37
+ )
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
@@ -12,6 +12,18 @@ module Nexus
12
12
 
13
13
  const :id, Integer
14
14
  const :name, String
15
+
16
+ class << self
17
+ extend T::Sig
18
+
19
+ sig { params(response: T::Hash[String, T.untyped]).returns(Group) }
20
+ def from_response(response)
21
+ Group.new(
22
+ id: response["id"],
23
+ name: response["name"],
24
+ )
25
+ end
26
+ end
15
27
  end
16
28
  end
17
29
  end
@@ -11,6 +11,17 @@ module Nexus
11
11
  include ValueObject
12
12
 
13
13
  const :id, Integer
14
+
15
+ class << self
16
+ extend T::Sig
17
+
18
+ sig { params(response: T::Hash[String, T.untyped]).returns(LoginLink) }
19
+ def from_response(response)
20
+ LoginLink.new(
21
+ id: response["id"],
22
+ )
23
+ end
24
+ end
14
25
  end
15
26
  end
16
27
  end
@@ -1,9 +1,12 @@
1
1
  # typed: strict
2
2
  # frozen_string_literal: true
3
3
 
4
- require "nexus/invision/value_object"
5
4
  require "sorbet-runtime"
6
5
 
6
+ require "nexus/invision/value_object"
7
+ require "nexus/invision/resources/rank"
8
+ require "nexus/invision/resources/field_group"
9
+
7
10
  module Nexus
8
11
  module Invision
9
12
  module Resources
@@ -12,7 +15,44 @@ module Nexus
12
15
  include ValueObject
13
16
 
14
17
  const :id, Integer
18
+ # const :name, String
19
+ # const :title, T.nilable(String)
20
+ # const :timeZone, String
21
+ # const :formattedName, String
15
22
  const :primaryGroup, Group
23
+ # const :secondaryGroups, T::Array[Group]
24
+ # const :email, String
25
+ # const :joined, Time
26
+ # const :registrationIpAddress, String
27
+ # const :warningPoints, Integer
28
+ # const :reputationPoints, Integer
29
+ # const :photoUrl, String
30
+ # const :photoUrlIsDefault, T::Boolean
31
+ # const :coverPhotoUrl, String
32
+ # const :profileUrl, T.nilable(String)
33
+ # const :validating, T::Boolean
34
+ # const :posts, Integer
35
+ # const :lastActivity, Time
36
+ # const :lastVisit, Time
37
+ # const :birthday, Date
38
+ # const :profileViews, Integer
39
+ # const :customFields, T::Hash[String, FieldGroup]
40
+ # const :rank, Rank
41
+ # const :achievements_points, Integer
42
+ # const :allowAdminEmails, T::Boolean
43
+ # const :completed, T::Boolean
44
+
45
+ class << self
46
+ extend T::Sig
47
+
48
+ sig { params(response: T::Hash[String, T.untyped]).returns(Member) }
49
+ def from_response(response)
50
+ Member.new(
51
+ id: response["id"],
52
+ primaryGroup: Group.from_response(response["primaryGroup"]),
53
+ )
54
+ end
55
+ end
16
56
  end
17
57
  end
18
58
  end
@@ -0,0 +1,38 @@
1
+ # typed: strict
2
+ # frozen_string_literal: true
3
+
4
+ require "sorbet-runtime"
5
+
6
+ require "nexus/invision/resources/question"
7
+ require "nexus/invision/value_object"
8
+
9
+ module Nexus
10
+ module Invision
11
+ module Resources
12
+ # Member is a User with additional information about their membership.
13
+ class Poll < T::Struct
14
+ include ValueObject
15
+
16
+ const :id, Integer
17
+ # const :title, String
18
+ # const :start_date, DateTime
19
+ # const :closed, T::Boolean
20
+ # const :closedDate, String
21
+ # const :public, T::Boolean
22
+ # const :votes, Integer
23
+ # const :questions, T::Array[Question]
24
+
25
+ class << self
26
+ extend T::Sig
27
+
28
+ sig { params(response: T::Hash[String, T.untyped]).returns(Poll) }
29
+ def from_response(response)
30
+ Poll.new(
31
+ id: response["id"],
32
+ )
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
@@ -1,9 +1,11 @@
1
1
  # typed: strict
2
2
  # frozen_string_literal: true
3
3
 
4
- require "nexus/invision/value_object"
5
4
  require "sorbet-runtime"
6
5
 
6
+ require "nexus/invision/value_object"
7
+ require "nexus/invision/resources/member"
8
+
7
9
  module Nexus
8
10
  module Invision
9
11
  module Resources
@@ -12,6 +14,24 @@ module Nexus
12
14
 
13
15
  const :id, Integer
14
16
  const :item_id, Integer
17
+ # const :author, Member
18
+ # const :date, Time
19
+ # const :content, String
20
+ # const :hidden, T::Boolean
21
+ # const :url, String
22
+ # const :reactions, T::Hash[String, T::Array[String]]
23
+
24
+ class << self
25
+ extend T::Sig
26
+
27
+ sig { params(response: T::Hash[String, T.untyped]).returns(Post) }
28
+ def from_response(response)
29
+ Post.new(
30
+ id: response["id"],
31
+ item_id: response["item_id"],
32
+ )
33
+ end
34
+ end
15
35
  end
16
36
  end
17
37
  end
@@ -0,0 +1,32 @@
1
+ # typed: strict
2
+ # frozen_string_literal: true
3
+
4
+ require "sorbet-runtime"
5
+
6
+ require "nexus/invision/value_object"
7
+
8
+ module Nexus
9
+ module Invision
10
+ module Resources
11
+ # Member is a User with additional information about their membership.
12
+ class Question < T::Struct
13
+ include ValueObject
14
+
15
+ const :question, String
16
+ const :options, T::Hash[String, T.untyped]
17
+
18
+ class << self
19
+ extend T::Sig
20
+
21
+ sig { params(response: T::Hash[String, T.untyped]).returns(Question) }
22
+ def from_response(response)
23
+ Question.new(
24
+ question: response["question"],
25
+ options: response["options"],
26
+ )
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,33 @@
1
+ # typed: strict
2
+ # frozen_string_literal: true
3
+
4
+ require "sorbet-runtime"
5
+
6
+ module Nexus
7
+ module Invision
8
+ module Resources
9
+ class Rank < T::Struct
10
+ include ValueObject
11
+
12
+ const :id, Integer
13
+ const :name, String
14
+ const :icon, String
15
+ const :points, Integer
16
+
17
+ class << self
18
+ extend T::Sig
19
+
20
+ sig { params(response: T::Hash[String, T.untyped]).returns(Rank) }
21
+ def from_response(response)
22
+ Rank.new(
23
+ id: response["id"],
24
+ name: response["name"],
25
+ icon: response["icon"],
26
+ points: response["points"],
27
+ )
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
@@ -2,6 +2,9 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  require "nexus/invision/value_object"
5
+ require "nexus/invision/resources/forum"
6
+ require "nexus/invision/resources/post"
7
+ require "nexus/invision/resources/poll"
5
8
  require "sorbet-runtime"
6
9
 
7
10
  module Nexus
@@ -12,6 +15,40 @@ module Nexus
12
15
 
13
16
  const :id, Integer
14
17
  const :title, String
18
+ # const :forum, Forum
19
+ # const :posts, Integer
20
+ # const :views, Integer
21
+ # const :prefix, String
22
+ # const :tags, T::Array[String]
23
+ const :first_post, T.nilable(Post), default: nil
24
+ const :last_post, T.nilable(Post), default: nil
25
+ # const :best_answer, T.nilable(Post)
26
+ # const :locked, T::Boolean
27
+ # const :hidden, T::Boolean
28
+ # const :pinned, T::Boolean
29
+ # const :featured, T::Boolean
30
+ # const :archived, T::Boolean
31
+ # const :poll, Poll
32
+ # const :url, String
33
+ # const :rating, Float
34
+
35
+ class << self
36
+ extend T::Sig
37
+
38
+ sig { params(response: T::Hash[String, T.untyped]).returns(Topic) }
39
+ def from_response(response)
40
+ Resources::Topic.new(
41
+ id: response["id"],
42
+ title: response["title"],
43
+ first_post: response["firstPost"]&.then do |fp|
44
+ Resources::Post.from_response(fp)
45
+ end,
46
+ last_post: response["lastPost"]&.then do |lp|
47
+ Resources::Post.from_response(lp)
48
+ end,
49
+ )
50
+ end
51
+ end
15
52
  end
16
53
  end
17
54
  end
@@ -11,6 +11,17 @@ module Nexus
11
11
  include ValueObject
12
12
 
13
13
  const :count, Integer
14
+
15
+ class << self
16
+ extend T::Sig
17
+
18
+ sig { params(response: T::Hash[String, T.untyped]).returns(UnreadCount) }
19
+ def from_response(response)
20
+ UnreadCount.new(
21
+ count: response["count"],
22
+ )
23
+ end
24
+ end
14
25
  end
15
26
  end
16
27
  end
@@ -11,6 +11,17 @@ module Nexus
11
11
  include ValueObject
12
12
 
13
13
  const :id, Integer
14
+
15
+ class << self
16
+ extend T::Sig
17
+
18
+ sig { params(response: T::Hash[String, T.untyped]).returns(User) }
19
+ def from_response(response)
20
+ User.new(
21
+ id: Integer(response["id"]),
22
+ )
23
+ end
24
+ end
14
25
  end
15
26
  end
16
27
  end
@@ -11,6 +11,17 @@ module Nexus
11
11
  include ValueObject
12
12
 
13
13
  const :id, Integer
14
+
15
+ class << self
16
+ extend T::Sig
17
+
18
+ sig { params(response: T::Hash[String, T.untyped]).returns(Warning) }
19
+ def from_response(response)
20
+ Warning.new(
21
+ id: response["id"],
22
+ )
23
+ end
24
+ end
14
25
  end
15
26
  end
16
27
  end