harkness 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. checksums.yaml +7 -0
  2. data/.rubocop.yml +94 -0
  3. data/.yardopts +1 -0
  4. data/CHANGELOG.md +5 -0
  5. data/CODE_OF_CONDUCT.md +84 -0
  6. data/CONTRIBUTING.MD +91 -0
  7. data/Gemfile +7 -0
  8. data/LICENSE.txt +21 -0
  9. data/README.md +155 -0
  10. data/Rakefile +12 -0
  11. data/harkness.gemspec +42 -0
  12. data/lib/harkness/client.rb +70 -0
  13. data/lib/harkness/error.rb +63 -0
  14. data/lib/harkness/models/base/data_container.rb +21 -0
  15. data/lib/harkness/models/base/data_wrapper.rb +34 -0
  16. data/lib/harkness/models/base/summary.rb +17 -0
  17. data/lib/harkness/models/character.rb +54 -0
  18. data/lib/harkness/models/character_list.rb +27 -0
  19. data/lib/harkness/models/comic.rb +53 -0
  20. data/lib/harkness/models/comic_list.rb +12 -0
  21. data/lib/harkness/models/creator.rb +28 -0
  22. data/lib/harkness/models/creator_list.rb +14 -0
  23. data/lib/harkness/models/event.rb +30 -0
  24. data/lib/harkness/models/event_list.rb +12 -0
  25. data/lib/harkness/models/image.rb +9 -0
  26. data/lib/harkness/models/series.rb +32 -0
  27. data/lib/harkness/models/series_list.rb +12 -0
  28. data/lib/harkness/models/story.rb +26 -0
  29. data/lib/harkness/models/story_list.rb +13 -0
  30. data/lib/harkness/models/text_object.rb +10 -0
  31. data/lib/harkness/models/url.rb +9 -0
  32. data/lib/harkness/resource.rb +36 -0
  33. data/lib/harkness/resources/character.rb +63 -0
  34. data/lib/harkness/resources/comic.rb +63 -0
  35. data/lib/harkness/resources/creator.rb +63 -0
  36. data/lib/harkness/resources/event.rb +72 -0
  37. data/lib/harkness/resources/series.rb +72 -0
  38. data/lib/harkness/resources/story.rb +72 -0
  39. data/lib/harkness/version.rb +5 -0
  40. data/lib/harkness.rb +42 -0
  41. metadata +254 -0
@@ -0,0 +1,72 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Harkness
4
+ # The event resource.
5
+ class EventResource < Resource
6
+ # Get a list of events.
7
+ # @param params [Hash] the params to pass to the API request.
8
+ # See the [events documentation from Marvel](https://developer.marvel.com/docs#!/public/getCreatorCollection_get_12)
9
+ # for valid options.
10
+ # @return [Harkness::EventDataWrapper] the top level wrapper around the event API response.
11
+ # @example
12
+ # client.events.list
13
+ # client.events.list(nameStartsWith: "2016", limit: 10, orderBy: "-name")
14
+ def list(**params)
15
+ EventDataWrapper.from_json(get_request("events", params: params).body)
16
+ end
17
+
18
+ # Get a single event.
19
+ # @param event_id [Integer] the ID of the event.
20
+ # @return [Harkness::EventDataWrapper] the top level wrapper around the event API response.
21
+ # @example
22
+ # client.events.retrieve(event_id: 1234)
23
+ def retrieve(event_id:)
24
+ EventDataWrapper.from_json(get_request("events/#{event_id}").body)
25
+ end
26
+
27
+ # Get a list of comics for a particular event.
28
+ # @param event_id [Integer] the ID of the event.
29
+ # @return [Harkness::ComicDataWrapper] the top level wrapper around the comic API response.
30
+ # @example
31
+ # client.events.comics(event_id: 1234)
32
+ def comics(event_id:)
33
+ ComicDataWrapper.from_json(get_request("events/#{event_id}/comics").body)
34
+ end
35
+
36
+ # Get a list of series for a particular event.
37
+ # @param event_id [Integer] the ID of the event.
38
+ # @return [Harkness::SeriesDataWrapper] the top level wrapper around the series API response.
39
+ # @example
40
+ # client.events.series(event_id: 1234)
41
+ def series(event_id:)
42
+ SeriesDataWrapper.from_json(get_request("events/#{event_id}/series").body)
43
+ end
44
+
45
+ # Get a list of stories for a particular event.
46
+ # @param event_id [Integer] the ID of the event.
47
+ # @return [Harkness::StoryDataWrapper] the top level wrapper around the story API response.
48
+ # @example
49
+ # client.events.stories(event_id: 1234)
50
+ def stories(event_id:)
51
+ StoryDataWrapper.from_json(get_request("events/#{event_id}/stories").body)
52
+ end
53
+
54
+ # Get a list of characters for a particular event.
55
+ # @param event_id [Integer] the ID of the event.
56
+ # @return [Harkness::CharaacterDataWrapper] the top level wrapper around the event API response.
57
+ # @example
58
+ # client.events.characters(event_id: 1234)
59
+ def characters(event_id:)
60
+ CharacterDataWrapper.from_json(get_request("events/#{event_id}/characters").body)
61
+ end
62
+
63
+ # Get a list of creators for a particular event.
64
+ # @param event_id [Integer] the ID of the event.
65
+ # @return [Harkness::CreatorDataWrapper] the top level wrapper around the creator API response.
66
+ # @example
67
+ # client.events.creators(event_id: 1234)
68
+ def creators(event_id:)
69
+ CreatorDataWrapper.from_json(get_request("events/#{event_id}/creators").body)
70
+ end
71
+ end
72
+ end
@@ -0,0 +1,72 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Harkness
4
+ # The series resource.
5
+ class SeriesResource < Resource
6
+ # Get a list of series.
7
+ # @param params [Hash] the params to pass to the API request.
8
+ # See the [series documentation from Marvel](https://developer.marvel.com/docs#!/public/getCreatorCollection_get_12)
9
+ # for valid options.
10
+ # @return [Harkness::SeriesDataWrapper] the top level wrapper around the series API response.
11
+ # @example
12
+ # client.series.list
13
+ # client.series.list(titleStartsWith: "Ant-", limit: 10, orderBy: "title")
14
+ def list(**params)
15
+ SeriesDataWrapper.from_json(get_request("series", params: params).body)
16
+ end
17
+
18
+ # Get a single series.
19
+ # @param series_id [Integer] the ID of the series.
20
+ # @return [Harkness::SeriesDataWrapper] the top level wrapper around the series API response.
21
+ # @example
22
+ # client.series.retrieve(series_id: 1234)
23
+ def retrieve(series_id:)
24
+ SeriesDataWrapper.from_json(get_request("series/#{series_id}").body)
25
+ end
26
+
27
+ # Get a list of comics for a particular series.
28
+ # @param series_id [Integer] the ID of the series.
29
+ # @return [Harkness::ComicDataWrapper] the top level wrapper around the comic API response.
30
+ # @example
31
+ # client.series.comics(series_id: 1234)
32
+ def comics(series_id:)
33
+ ComicDataWrapper.from_json(get_request("series/#{series_id}/comics").body)
34
+ end
35
+
36
+ # Get a list of stories for a particular series.
37
+ # @param series_id [Integer] the ID of the series.
38
+ # @return [Harkness::StoryDataWrapper] the top level wrapper around the story API response.
39
+ # @example
40
+ # client.series.stories(series_id: 1234)
41
+ def stories(series_id:)
42
+ StoryDataWrapper.from_json(get_request("series/#{series_id}/stories").body)
43
+ end
44
+
45
+ # Get a list of characters for a particular series.
46
+ # @param series_id [Integer] the ID of the series.
47
+ # @return [Harkness::CharacterDataWrapper] the top level wrapper around the character API response.
48
+ # @example
49
+ # client.series.characters(series_id: 1234)
50
+ def characters(series_id:)
51
+ CharacterDataWrapper.from_json(get_request("series/#{series_id}/characters").body)
52
+ end
53
+
54
+ # Get a list of creators for a particular series.
55
+ # @param series_id [Integer] the ID of the series.
56
+ # @return [Harkness::CreatorDataWrapper] the top level wrapper around the creator API response.
57
+ # @example
58
+ # client.series.creators(series_id: 1234)
59
+ def creators(series_id:)
60
+ CreatorDataWrapper.from_json(get_request("series/#{series_id}/creators").body)
61
+ end
62
+
63
+ # Get a list of events for a particular series.
64
+ # @param series_id [Integer] the ID of the series.
65
+ # @return [Harkness::EventDataWrapper] the top level wrapper around the event API response.
66
+ # @example
67
+ # client.series.events(series_id: 1234)
68
+ def events(series_id:)
69
+ EventDataWrapper.from_json(get_request("series/#{series_id}/events").body)
70
+ end
71
+ end
72
+ end
@@ -0,0 +1,72 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Harkness
4
+ # The story resource.
5
+ class StoryResource < Resource
6
+ # Get a list of stories.
7
+ # @param params [Hash] the params to pass to the API request.
8
+ # See the [stories documentation from Marvel](https://developer.marvel.com/docs#!/public/getCreatorCollection_get_12)
9
+ # for valid options.
10
+ # @return [Harkness::StoryDataWrapper] the top level wrapper around the story API response.
11
+ # @example
12
+ # client.stories.list
13
+ # client.stories.list(creators: "1234", limit: 10, orderBy: "id")
14
+ def list(**params)
15
+ StoryDataWrapper.from_json(get_request("stories", params: params).body)
16
+ end
17
+
18
+ # Get a single story.
19
+ # @param story_id [Integer] the ID of the story.
20
+ # @return [Harkness::StoryDataWrapper] the top level wrapper around the story API response.
21
+ # @example
22
+ # client.stories.retrieve(story_id: 1234)
23
+ def retrieve(story_id:)
24
+ StoryDataWrapper.from_json(get_request("stories/#{story_id}").body)
25
+ end
26
+
27
+ # Get a list of comics for a particular story.
28
+ # @param story_id [Integer] the ID of the story.
29
+ # @return [Harkness::ComicDataWrapper] the top level wrapper around the comic API response.
30
+ # @example
31
+ # client.stories.comics(story_id: 1234)
32
+ def comics(story_id:)
33
+ ComicDataWrapper.from_json(get_request("stories/#{story_id}/comics").body)
34
+ end
35
+
36
+ # Get a list of events for a particular story.
37
+ # @param story_id [Integer] the ID of the story.
38
+ # @return [Harkness::EventDataWrapper] the top level wrapper around the event API response.
39
+ # @example
40
+ # client.stories.events(story_id: 1234)
41
+ def events(story_id:)
42
+ EventDataWrapper.from_json(get_request("stories/#{story_id}/events").body)
43
+ end
44
+
45
+ # Get a list of series for a particular story.
46
+ # @param story_id [Integer] the ID of the story.
47
+ # @return [Harkness::SeriesDataWrapper] the top level wrapper around the series API response.
48
+ # @example
49
+ # client.stories.series(story_id: 1234)
50
+ def series(story_id:)
51
+ SeriesDataWrapper.from_json(get_request("stories/#{story_id}/series").body)
52
+ end
53
+
54
+ # Get a list of characters for a particular story.
55
+ # @param story_id [Integer] the ID of the story.
56
+ # @return [Harkness::CharacterDataWrapper] the top level wrapper around the character API response.
57
+ # @example
58
+ # client.stories.characters(story_id: 1234)
59
+ def characters(story_id:)
60
+ CharacterDataWrapper.from_json(get_request("stories/#{story_id}/characters").body)
61
+ end
62
+
63
+ # Get a list of creators for a particular story.
64
+ # @param story_id [Integer] the ID of the story.
65
+ # @return [Harkness::CreatorDataWrapper] the top level wrapper around the creator API response.
66
+ # @example
67
+ # client.stories.creators(story_id: 1234)
68
+ def creators(story_id:)
69
+ CreatorDataWrapper.from_json(get_request("stories/#{story_id}/creators").body)
70
+ end
71
+ end
72
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Harkness
4
+ VERSION = "1.0.0"
5
+ end
data/lib/harkness.rb ADDED
@@ -0,0 +1,42 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "faraday"
4
+ require "shale"
5
+
6
+ # Harkness
7
+ require "harkness/version"
8
+ require "harkness/client"
9
+ require "harkness/resource"
10
+ require "harkness/error"
11
+
12
+ # Base objects
13
+ require "harkness/models/base/data_container"
14
+ require "harkness/models/base/data_wrapper"
15
+ require "harkness/models/base/summary"
16
+
17
+ # Shared models
18
+ require "harkness/models/text_object"
19
+ require "harkness/models/image"
20
+ require "harkness/models/url"
21
+ require "harkness/models/comic_list"
22
+ require "harkness/models/creator_list"
23
+ require "harkness/models/character_list"
24
+ require "harkness/models/event_list"
25
+ require "harkness/models/story_list"
26
+ require "harkness/models/series_list"
27
+
28
+ # Models
29
+ require "harkness/models/character"
30
+ require "harkness/models/comic"
31
+ require "harkness/models/creator"
32
+ require "harkness/models/event"
33
+ require "harkness/models/series"
34
+ require "harkness/models/story"
35
+
36
+ # Resources
37
+ require "harkness/resources/character"
38
+ require "harkness/resources/comic"
39
+ require "harkness/resources/creator"
40
+ require "harkness/resources/event"
41
+ require "harkness/resources/series"
42
+ require "harkness/resources/story"
metadata ADDED
@@ -0,0 +1,254 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: harkness
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - duffn
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2023-03-12 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: faraday
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '2.7'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '2.7'
27
+ - !ruby/object:Gem::Dependency
28
+ name: shale
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 0.9.0
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 0.9.0
41
+ - !ruby/object:Gem::Dependency
42
+ name: redcarpet
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.6'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.6'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '3.12'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '3.12'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rubocop-rake
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: 0.6.0
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: 0.6.0
83
+ - !ruby/object:Gem::Dependency
84
+ name: rubocop-rspec
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '2.18'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '2.18'
97
+ - !ruby/object:Gem::Dependency
98
+ name: simplecov
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: 0.22.0
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: 0.22.0
111
+ - !ruby/object:Gem::Dependency
112
+ name: simplecov-cobertura
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '2.1'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: '2.1'
125
+ - !ruby/object:Gem::Dependency
126
+ name: timecop
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - "~>"
130
+ - !ruby/object:Gem::Version
131
+ version: 0.9.6
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - "~>"
137
+ - !ruby/object:Gem::Version
138
+ version: 0.9.6
139
+ - !ruby/object:Gem::Dependency
140
+ name: vcr
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - "~>"
144
+ - !ruby/object:Gem::Version
145
+ version: '6.1'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - "~>"
151
+ - !ruby/object:Gem::Version
152
+ version: '6.1'
153
+ - !ruby/object:Gem::Dependency
154
+ name: webmock
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - "~>"
158
+ - !ruby/object:Gem::Version
159
+ version: '3.18'
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - "~>"
165
+ - !ruby/object:Gem::Version
166
+ version: '3.18'
167
+ - !ruby/object:Gem::Dependency
168
+ name: yard
169
+ requirement: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - "~>"
172
+ - !ruby/object:Gem::Version
173
+ version: 0.9.28
174
+ type: :development
175
+ prerelease: false
176
+ version_requirements: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - "~>"
179
+ - !ruby/object:Gem::Version
180
+ version: 0.9.28
181
+ description: Dive into the Marvel universe with this comprehensive Ruby library for
182
+ the Marvel API at https://developer.marvel.com.
183
+ email:
184
+ executables: []
185
+ extensions: []
186
+ extra_rdoc_files: []
187
+ files:
188
+ - ".rubocop.yml"
189
+ - ".yardopts"
190
+ - CHANGELOG.md
191
+ - CODE_OF_CONDUCT.md
192
+ - CONTRIBUTING.MD
193
+ - Gemfile
194
+ - LICENSE.txt
195
+ - README.md
196
+ - Rakefile
197
+ - harkness.gemspec
198
+ - lib/harkness.rb
199
+ - lib/harkness/client.rb
200
+ - lib/harkness/error.rb
201
+ - lib/harkness/models/base/data_container.rb
202
+ - lib/harkness/models/base/data_wrapper.rb
203
+ - lib/harkness/models/base/summary.rb
204
+ - lib/harkness/models/character.rb
205
+ - lib/harkness/models/character_list.rb
206
+ - lib/harkness/models/comic.rb
207
+ - lib/harkness/models/comic_list.rb
208
+ - lib/harkness/models/creator.rb
209
+ - lib/harkness/models/creator_list.rb
210
+ - lib/harkness/models/event.rb
211
+ - lib/harkness/models/event_list.rb
212
+ - lib/harkness/models/image.rb
213
+ - lib/harkness/models/series.rb
214
+ - lib/harkness/models/series_list.rb
215
+ - lib/harkness/models/story.rb
216
+ - lib/harkness/models/story_list.rb
217
+ - lib/harkness/models/text_object.rb
218
+ - lib/harkness/models/url.rb
219
+ - lib/harkness/resource.rb
220
+ - lib/harkness/resources/character.rb
221
+ - lib/harkness/resources/comic.rb
222
+ - lib/harkness/resources/creator.rb
223
+ - lib/harkness/resources/event.rb
224
+ - lib/harkness/resources/series.rb
225
+ - lib/harkness/resources/story.rb
226
+ - lib/harkness/version.rb
227
+ homepage: https://github.com/duffn/harkness
228
+ licenses:
229
+ - MIT
230
+ metadata:
231
+ allowed_push_host: https://rubygems.org
232
+ homepage_uri: https://github.com/duffn/harkness
233
+ source_code_uri: https://github.com/duffn/harkness
234
+ changelog_uri: https://github.com/duffn/harkness/blob/main/CHANGELOG.md
235
+ post_install_message:
236
+ rdoc_options: []
237
+ require_paths:
238
+ - lib
239
+ required_ruby_version: !ruby/object:Gem::Requirement
240
+ requirements:
241
+ - - ">="
242
+ - !ruby/object:Gem::Version
243
+ version: 2.6.0
244
+ required_rubygems_version: !ruby/object:Gem::Requirement
245
+ requirements:
246
+ - - ">="
247
+ - !ruby/object:Gem::Version
248
+ version: '0'
249
+ requirements: []
250
+ rubygems_version: 3.4.6
251
+ signing_key:
252
+ specification_version: 4
253
+ summary: A library for working (playing) with the Marvel API.
254
+ test_files: []