nexus-invision 1.0.1 → 1.2.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 065f4b649c4cb38fd6e74ee2553e765d54aeac82c87ee1a0228bde20d67ee5ba
4
- data.tar.gz: be4eef47364841e72cbe4e3a4d6a30ffcd40da45473cba3da0071c255c51bdee
3
+ metadata.gz: 0d4f567b2a4319ba9f7370165b9f88461134e1a6265f18effcdcb35339c16e32
4
+ data.tar.gz: 6bb7205017fe2d53d1030da35b1679dc2404b6b269a6e82415b542a591ce1448
5
5
  SHA512:
6
- metadata.gz: 9c4b65c458d3b1223ad798d26abcfce4dd7573fdc0a4373dceb351662edddf78430a8faa8fc2dbb0ce7acace4f719d6eebb8c3e46abe17eb979c73a49f819fca
7
- data.tar.gz: 5ec905d67b971c2478405b90f684a86f4e116dea933cc3eb5f4b08fb985a6abd5c239fb45fee0985b336cc7ae880c9a137062c87ccd1af9429cc23b8f5ae7206
6
+ metadata.gz: c97adf9ba3d36c361ab8c1674ed7935dc09fb6ef281f2d1ff34382293e8d74ef0edcedbc2099aef8a1bdf28ac100c8388b3a090a598a861684916ca15be9535d
7
+ data.tar.gz: f3010a5fe7410a594456f45c3d95700ca6fc6e2ef9f70770c1c6370fd194747d94f6867dbacdc395f0f9655f25841c21f9b5299da2f6194d8ef621375533176e
@@ -5,10 +5,14 @@ require "faraday"
5
5
  require "nexus/invision/errors/bad_request"
6
6
  require "nexus/invision/errors/unexpected_response"
7
7
  require "nexus/invision/requests/add_member_to_secondary_group"
8
+ require "nexus/invision/requests/create_forum_post"
8
9
  require "nexus/invision/requests/create_forum_topic"
9
10
  require "nexus/invision/requests/create_member_warning"
11
+ require "nexus/invision/requests/list_forum_topics"
10
12
  require "nexus/invision/requests/remove_member_from_secondary_group"
11
13
  require "nexus/invision/resources/login_link"
14
+ require "nexus/invision/resources/page"
15
+ require "nexus/invision/resources/post"
12
16
  require "nexus/invision/resources/topic"
13
17
  require "nexus/invision/resources/user"
14
18
  require "nexus/invision/resources/warning"
@@ -55,6 +59,25 @@ module Nexus
55
59
  end
56
60
  end
57
61
 
62
+ sig { params(request: Requests::ListForumTopics).returns(Resources::Page[Resources::Topic]) }
63
+ def list_forum_topics(request)
64
+ response = request(
65
+ http_method: HTTPMethod::GET,
66
+ endpoint: URI("forums/topics"),
67
+ params: request.serialize,
68
+ )
69
+
70
+ body = response.body
71
+
72
+ Resources::Page[Resources::Topic].new(
73
+ page: body.fetch("page"),
74
+ per_page: body.fetch("perPage"),
75
+ total_results: body.fetch("totalResults"),
76
+ total_pages: body.fetch("totalPages"),
77
+ results: body.fetch("results").map { |result| Resources::Topic.from_hash(result) },
78
+ )
79
+ end
80
+
58
81
  sig { params(request: Requests::CreateForumTopic).returns(Resources::Topic) }
59
82
  def create_forum_topic(request)
60
83
  response = request(
@@ -66,6 +89,17 @@ module Nexus
66
89
  Resources::Topic.from_hash(response.body)
67
90
  end
68
91
 
92
+ sig { params(request: Requests::CreateForumPost).returns(Resources::Post) }
93
+ def create_forum_post(request)
94
+ response = request(
95
+ http_method: HTTPMethod::POST,
96
+ endpoint: URI("forums/posts"),
97
+ params: request.serialize,
98
+ )
99
+
100
+ Resources::Post.from_hash(response.body)
101
+ end
102
+
69
103
  sig { params(nexusmods_member_id: Integer).returns(Resources::LoginLink) }
70
104
  def login_link(nexusmods_member_id)
71
105
  response = request(
@@ -0,0 +1,19 @@
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 CreateForumPost < T::Struct
11
+ include ValueObject
12
+
13
+ const :topic, Integer
14
+ const :author, Integer
15
+ const :post, String
16
+ end
17
+ end
18
+ end
19
+ end
@@ -10,7 +10,7 @@ module Nexus
10
10
  class CreateForumTopic < T::Struct
11
11
  include ValueObject
12
12
 
13
- const :forum_id, Integer
13
+ const :forum, Integer
14
14
  const :title, String
15
15
  const :post, String
16
16
  const :author, T.nilable(Integer)
@@ -0,0 +1,24 @@
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 ListForumTopics < T::Struct
11
+ include ValueObject
12
+
13
+ const :forums, String # A comma delimited list of forum IDs
14
+ const :sort_by, String, name: "sortBy", default: "updated"
15
+ const :sort_dir, String, name: "sortDir", default: "desc"
16
+ const :per_page, Integer, name: "perPage", default: 100
17
+ const :has_poll, T::Boolean, name: "hasPoll", default: false
18
+ const :hidden, Integer, default: 0
19
+ const :archived, Integer, default: 0
20
+ const :locked, Integer, default: 0
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,48 @@
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 Page
11
+ extend T::Sig
12
+ extend T::Generic
13
+
14
+ include ValueObject
15
+
16
+ TResource = type_member { { upper: T::Struct } }
17
+
18
+ sig do
19
+ params(
20
+ page: Integer,
21
+ per_page: Integer,
22
+ total_results: Integer,
23
+ total_pages: Integer,
24
+ results: T::Array[TResource],
25
+ ).void
26
+ end
27
+ def initialize(page:, per_page:, total_results:, total_pages:, results:)
28
+ @page = page
29
+ @per_page = per_page
30
+ @total_results = total_results
31
+ @total_pages = total_pages
32
+ @results = results
33
+ end
34
+
35
+ sig { override.returns(T::Hash[String, T.untyped]) }
36
+ def serialize
37
+ {
38
+ "page" => @page,
39
+ "perPage" => @per_page,
40
+ "totalResults" => @total_results,
41
+ "totalPages" => @total_pages,
42
+ "results" => @results.map(&:serialize),
43
+ }
44
+ end
45
+ end
46
+ end
47
+ end
48
+ 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 Resources
10
+ class Post < T::Struct
11
+ include ValueObject
12
+
13
+ const :id, Integer
14
+ const :item_id, Integer
15
+ end
16
+ end
17
+ end
18
+ end
@@ -11,6 +11,7 @@ module Nexus
11
11
  include ValueObject
12
12
 
13
13
  const :id, Integer
14
+ const :title, String
14
15
  end
15
16
  end
16
17
  end
@@ -3,7 +3,7 @@
3
3
 
4
4
  module Nexus
5
5
  module Invision
6
- # Leave this as 1.0.1 in order for CI process to replace with the tagged version.
7
- VERSION = "1.0.1"
6
+ # Leave this as 1.2.0 in order for CI process to replace with the tagged version.
7
+ VERSION = "1.2.0"
8
8
  end
9
9
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nexus-invision
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jack Robertson
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-11-06 00:00:00.000000000 Z
11
+ date: 2023-11-08 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email:
@@ -27,10 +27,14 @@ files:
27
27
  - lib/nexus/invision/errors/client_error.rb
28
28
  - lib/nexus/invision/errors/unexpected_response.rb
29
29
  - lib/nexus/invision/requests/add_member_to_secondary_group.rb
30
+ - lib/nexus/invision/requests/create_forum_post.rb
30
31
  - lib/nexus/invision/requests/create_forum_topic.rb
31
32
  - lib/nexus/invision/requests/create_member_warning.rb
33
+ - lib/nexus/invision/requests/list_forum_topics.rb
32
34
  - lib/nexus/invision/requests/remove_member_from_secondary_group.rb
33
35
  - lib/nexus/invision/resources/login_link.rb
36
+ - lib/nexus/invision/resources/page.rb
37
+ - lib/nexus/invision/resources/post.rb
34
38
  - lib/nexus/invision/resources/topic.rb
35
39
  - lib/nexus/invision/resources/user.rb
36
40
  - lib/nexus/invision/resources/warning.rb