harkness 1.0.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 (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,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Harkness
4
+ module Base
5
+ # The top level wrapper of a response from the API.
6
+ class DataWrapper < Shale::Mapper
7
+ # @!attribute [r] code
8
+ # @return [Integer] the HTTP status code of the returned result.
9
+ attribute :code, Shale::Type::Integer
10
+ # @!attribute [r] status
11
+ # @return [String] a string description of the call status.
12
+ attribute :status, Shale::Type::String
13
+ # @!attribute [r] copyright
14
+ # @return [String] the copyright notice for the returned result.
15
+ attribute :copyright, Shale::Type::String
16
+ # @!attribute [r] attributionText
17
+ # @return [String] the attribution notice for this result.
18
+ # Please display either this notice or the contents of the attributionHTML field on all
19
+ # screens which contain data from the Marvel Comics API.
20
+ attribute :attributionText, Shale::Type::String
21
+ # @!attribute [r] attributionHTML
22
+ # @return [String] an HTML representation of the attribution notice for this result.
23
+ # Please display either this notice or the contents of the attributionText field on all
24
+ # screens which contain data from the Marvel Comics API.
25
+ attribute :attributionHTML, Shale::Type::String
26
+ # @!attribute [r] data
27
+ # @return [Harkness::Base::DataContainer] the results returned by the call.
28
+ attribute :data, Harkness::Base::DataContainer
29
+ # @!attribute [r] etag
30
+ # @return [String] a digest value of the content returned by the call.
31
+ attribute :etag, Shale::Type::String
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Harkness
4
+ module Base
5
+ # Base class for the "summary" objects in an API response. These summary objects are
6
+ # linked objects to the main API response. For example, when retrieving a Character,
7
+ # one of the summary objects is a Series.
8
+ class Summary < Shale::Mapper
9
+ # @!attribute [r] resourceURI
10
+ # @return [String] the path to the individual resource.
11
+ attribute :resourceURI, Shale::Type::String
12
+ # @!attribute [r] name
13
+ # @return [String] the canonical name of the resource.
14
+ attribute :name, Shale::Type::String
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,54 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Harkness
4
+ # An individual character.
5
+ class Character < Shale::Mapper
6
+ # @!attribute [r] id
7
+ # @return [Integer] the unique ID of the character resource.
8
+ attribute :id, Shale::Type::Integer
9
+ # @!attribute [r] name
10
+ # @return [String] the name of the character.
11
+ attribute :name, Shale::Type::String
12
+ # @!attribute [r] description
13
+ # @return [String] a short bio or description of the character
14
+ attribute :description, Shale::Type::String
15
+ # @!attribute [r] modified
16
+ # @return [String] the date the resource was most recently modified.
17
+ attribute :modified, Shale::Type::String
18
+ # @!attribute [r] resourceURI
19
+ # @return [String] the canonical URL identifier for this resource.
20
+ attribute :resourceURI, Shale::Type::String
21
+ # @!attribute [r] urls
22
+ # @return [Array<Harkness::URL>] a set of public web site URLs for the resource.
23
+ attribute :urls, Harkness::URL, collection: true
24
+ # @!attribute [r] thumbnail
25
+ # @return [Harkness::Image] the representative image for this character.
26
+ attribute :thumbnail, Harkness::Image
27
+ # @!attribute [r] comics
28
+ # @return [Harkness::ComicList] a resource list containing comics which feature this character.
29
+ attribute :comics, Harkness::ComicList
30
+ # @!attribute [r] stories
31
+ # @return [Harkness::StoryList] a resource list of stories in which this character appears.
32
+ attribute :stories, Harkness::StoryList
33
+ # @!attribute [r] events
34
+ # @return [Harkness::EventList] a resource list of events in which this character appears.
35
+ attribute :events, Harkness::EventList
36
+ # @!attribute [r] series
37
+ # @return [Harkness::SeriesList] a resource list of series in which this character appears.
38
+ attribute :series, Harkness::SeriesList
39
+ end
40
+
41
+ # Container class that holds pagination information and results
42
+ class CharacterDataContainer < Harkness::Base::DataContainer
43
+ # @!attribute [r] results
44
+ # @return [Array<Harkness::Character>] the list of characters returned by the call.
45
+ attribute :results, Harkness::Character, collection: true
46
+ end
47
+
48
+ # The top level wrapper of a response from the API.
49
+ class CharacterDataWrapper < Harkness::Base::DataWrapper
50
+ # @!attribute [r] data
51
+ # @return [CharacterDataContainer] the results returned by the call.
52
+ attribute :data, Harkness::CharacterDataContainer
53
+ end
54
+ end
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Harkness
4
+ # The summary of a character.
5
+ class CharacterSummary < Harkness::Base::Summary
6
+ # @!attribute [r] role
7
+ # @return [String] the role of the creator in the parent entity.
8
+ attribute :role, Shale::Type::String
9
+ end
10
+
11
+ # A list of characters.
12
+ class CharacterList < Shale::Mapper
13
+ # @!attribute [r] available
14
+ # @return [Integer] the number of total available characters in this list.
15
+ # Will always be greater than or equal to the "returned" value.
16
+ attribute :available, Shale::Type::Integer
17
+ # @!attribute [r] returned
18
+ # @return [Integer] the number of characters returned in this collection (up to 20).
19
+ attribute :returned, Shale::Type::Integer
20
+ # @!attribute [r] collectionURI
21
+ # @return [String] the path to the full list of characters in this collection.
22
+ attribute :collectionURI, Shale::Type::String
23
+ # @!attribute [r] offset
24
+ # @return [Array<Harkness::CharacterSummary>] the list of returned characters in this collection.
25
+ attribute :items, Harkness::CharacterSummary, collection: true
26
+ end
27
+ end
@@ -0,0 +1,53 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Harkness
4
+ class ComicDate < Shale::Mapper
5
+ attribute :type, Shale::Type::String
6
+ attribute :date, Shale::Type::String
7
+ end
8
+
9
+ class ComicPrice < Shale::Mapper
10
+ attribute :type, Shale::Type::String
11
+ attribute :price, Shale::Type::Float
12
+ end
13
+
14
+ class Comic < Shale::Mapper
15
+ attribute :id, Shale::Type::Integer
16
+ attribute :digitalId, Shale::Type::Integer
17
+ attribute :title, Shale::Type::String
18
+ attribute :issueNumber, Shale::Type::Integer
19
+ attribute :variantDescription, Shale::Type::String
20
+ attribute :description, Shale::Type::String
21
+ attribute :modified, Shale::Type::String
22
+ attribute :isbn, Shale::Type::String
23
+ attribute :upc, Shale::Type::String
24
+ attribute :diamondCode, Shale::Type::String
25
+ attribute :ean, Shale::Type::String
26
+ attribute :issn, Shale::Type::String
27
+ attribute :format, Shale::Type::String
28
+ attribute :pageCount, Shale::Type::Integer
29
+ attribute :textObjects, Harkness::TextObject, collection: true
30
+ attribute :resourceURI, Shale::Type::String
31
+ attribute :urls, Harkness::URL, collection: true
32
+ attribute :series, Harkness::SeriesSummary
33
+ attribute :variants, Harkness::ComicSummary, collection: true
34
+ attribute :collections, Harkness::ComicSummary, collection: true
35
+ attribute :collectedIssues, Harkness::ComicSummary, collection: true
36
+ attribute :dates, Harkness::ComicDate, collection: true
37
+ attribute :prices, Harkness::ComicPrice, collection: true
38
+ attribute :thumbnail, Harkness::Image
39
+ attribute :images, Harkness::Image, collection: true
40
+ attribute :creators, Harkness::CreatorList
41
+ attribute :characters, Harkness::CharacterList
42
+ attribute :stories, Harkness::StoryList
43
+ attribute :events, Harkness::EventList
44
+ end
45
+
46
+ class ComicDataContainer < Harkness::Base::DataContainer
47
+ attribute :results, Harkness::Comic, collection: true
48
+ end
49
+
50
+ class ComicDataWrapper < Harkness::Base::DataWrapper
51
+ attribute :data, Harkness::ComicDataContainer
52
+ end
53
+ end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Harkness
4
+ class ComicSummary < Harkness::Base::Summary
5
+ end
6
+
7
+ class ComicList < Shale::Mapper
8
+ attribute :available, Shale::Type::Integer
9
+ attribute :collectionURI, Shale::Type::String
10
+ attribute :items, Harkness::ComicSummary, collection: true
11
+ end
12
+ end
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Harkness
4
+ class Creator < Shale::Mapper
5
+ attribute :id, Shale::Type::Integer
6
+ attribute :firstName, Shale::Type::String
7
+ attribute :middleName, Shale::Type::String
8
+ attribute :lastName, Shale::Type::String
9
+ attribute :suffix, Shale::Type::String
10
+ attribute :fullName, Shale::Type::String
11
+ attribute :modified, Shale::Type::String
12
+ attribute :resourceURI, Shale::Type::String
13
+ attribute :urls, Harkness::URL, collection: true
14
+ attribute :thumbnail, Harkness::Image
15
+ attribute :series, Harkness::SeriesList
16
+ attribute :stories, Harkness::StoryList
17
+ attribute :comics, Harkness::ComicList
18
+ attribute :events, Harkness::EventList
19
+ end
20
+
21
+ class CreatorDataContainer < Harkness::Base::DataContainer
22
+ attribute :results, Harkness::Creator, collection: true
23
+ end
24
+
25
+ class CreatorDataWrapper < Harkness::Base::DataWrapper
26
+ attribute :data, Harkness::CreatorDataContainer
27
+ end
28
+ end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Harkness
4
+ class CreatorSummary < Harkness::Base::Summary
5
+ attribute :role, Shale::Type::String
6
+ end
7
+
8
+ class CreatorList < Shale::Mapper
9
+ attribute :available, Shale::Type::Integer
10
+ attribute :returned, Shale::Type::Integer
11
+ attribute :collectionURI, Shale::Type::String
12
+ attribute :items, Harkness::CreatorSummary, collection: true
13
+ end
14
+ end
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Harkness
4
+ class Event < Shale::Mapper
5
+ attribute :id, Shale::Type::Integer
6
+ attribute :title, Shale::Type::String
7
+ attribute :description, Shale::Type::String
8
+ attribute :resourceURI, Shale::Type::String
9
+ attribute :urls, Harkness::URL, collection: true
10
+ attribute :modified, Shale::Type::String
11
+ attribute :start, Shale::Type::String
12
+ attribute :end, Shale::Type::String
13
+ attribute :thumbnail, Harkness::Image
14
+ attribute :comics, Harkness::ComicList
15
+ attribute :stories, Harkness::StoryList
16
+ attribute :series, Harkness::SeriesList
17
+ attribute :characters, Harkness::CharacterList
18
+ attribute :creators, Harkness::CreatorList
19
+ attribute :next, Harkness::EventSummary
20
+ attribute :previous, Harkness::EventSummary
21
+ end
22
+
23
+ class EventDataContainer < Harkness::Base::DataContainer
24
+ attribute :results, Harkness::Event, collection: true
25
+ end
26
+
27
+ class EventDataWrapper < Harkness::Base::DataWrapper
28
+ attribute :data, Harkness::EventDataContainer
29
+ end
30
+ end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Harkness
4
+ class EventSummary < Harkness::Base::Summary
5
+ end
6
+
7
+ class EventList < Shale::Mapper
8
+ attribute :available, Shale::Type::Integer
9
+ attribute :collectionURI, Shale::Type::String
10
+ attribute :items, Harkness::EventSummary, collection: true
11
+ end
12
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Harkness
4
+ # An image.
5
+ class Image < Shale::Mapper
6
+ attribute :path, Shale::Type::String
7
+ attribute :extension, Shale::Type::String
8
+ end
9
+ end
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Harkness
4
+ class Series < Shale::Mapper
5
+ attribute :id, Shale::Type::Integer
6
+ attribute :title, Shale::Type::String
7
+ attribute :description, Shale::Type::String
8
+ attribute :resourceURI, Shale::Type::String
9
+ attribute :urls, Harkness::URL, collection: true
10
+
11
+ attribute :startYear, Shale::Type::Integer
12
+ attribute :endYear, Shale::Type::Integer
13
+ attribute :rating, Shale::Type::String
14
+ attribute :modified, Shale::Type::String
15
+ attribute :thumbnail, Harkness::Image
16
+ attribute :comics, Harkness::ComicList
17
+ attribute :stories, Harkness::StoryList
18
+ attribute :events, Harkness::EventList
19
+ attribute :characters, Harkness::CharacterList
20
+ attribute :creators, Harkness::CreatorList
21
+ attribute :next, Harkness::SeriesSummary
22
+ attribute :previous, Harkness::SeriesSummary
23
+ end
24
+
25
+ class SeriesDataContainer < Harkness::Base::DataContainer
26
+ attribute :results, Harkness::Series, collection: true
27
+ end
28
+
29
+ class SeriesDataWrapper < Harkness::Base::DataWrapper
30
+ attribute :data, Harkness::SeriesDataContainer
31
+ end
32
+ end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Harkness
4
+ class SeriesSummary < Harkness::Base::Summary
5
+ end
6
+
7
+ class SeriesList < Shale::Mapper
8
+ attribute :available, Shale::Type::Integer
9
+ attribute :collectionURI, Shale::Type::String
10
+ attribute :items, Harkness::SeriesSummary, collection: true
11
+ end
12
+ end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Harkness
4
+ class Story < Shale::Mapper
5
+ attribute :id, Shale::Type::Integer
6
+ attribute :title, Shale::Type::String
7
+ attribute :description, Shale::Type::String
8
+ attribute :resourceURI, Shale::Type::String
9
+ attribute :type, Shale::Type::String
10
+ attribute :modified, Shale::Type::String
11
+ attribute :thumbnail, Harkness::Image
12
+ attribute :comics, Harkness::ComicList
13
+ attribute :series, Harkness::SeriesList
14
+ attribute :events, Harkness::EventList
15
+ attribute :characters, Harkness::CharacterList
16
+ attribute :originalIssue, Harkness::ComicSummary
17
+ end
18
+
19
+ class StoryDataContainer < Harkness::Base::DataContainer
20
+ attribute :results, Harkness::Story, collection: true
21
+ end
22
+
23
+ class StoryDataWrapper < Harkness::Base::DataWrapper
24
+ attribute :data, Harkness::StoryDataContainer
25
+ end
26
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Harkness
4
+ class StorySummary < Harkness::Base::Summary
5
+ attribute :type, Shale::Type::String
6
+ end
7
+
8
+ class StoryList < Shale::Mapper
9
+ attribute :available, Shale::Type::Integer
10
+ attribute :collectionURI, Shale::Type::String
11
+ attribute :items, Harkness::StorySummary, collection: true
12
+ end
13
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Harkness
4
+ # A text objct
5
+ class TextObject < Shale::Mapper
6
+ attribute :type, Shale::Type::String
7
+ attribute :language, Shale::Type::String
8
+ attribute :text, Shale::Type::String
9
+ end
10
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Harkness
4
+ # A URL.
5
+ class URL < Shale::Mapper
6
+ attribute :type, Shale::Type::String
7
+ attribute :url, Shale::Type::String
8
+ end
9
+ end
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "digest/md5"
4
+
5
+ module Harkness
6
+ class Resource
7
+ attr_reader :client
8
+
9
+ def initialize(client)
10
+ @client = client
11
+ end
12
+
13
+ private
14
+
15
+ def get_request(url, params: {}, headers: {})
16
+ handle_response client.connection.get(url, authentication_params.merge(params), headers)
17
+ end
18
+
19
+ def authentication_params
20
+ timestamp = Time.now.to_i
21
+ {
22
+ ts: timestamp,
23
+ apikey: @client.public_key,
24
+ hash: Digest::MD5.hexdigest(timestamp.to_s + @client.private_key + @client.public_key)
25
+ }
26
+ end
27
+
28
+ def handle_response(response)
29
+ error_klass = Harkness::Error::STATUS_MAPPINGS[response.status]
30
+ message = JSON.parse(response.body)["status"] || "API request failed with an unknown error."
31
+ raise error_klass, message if error_klass
32
+
33
+ response
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,63 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Harkness
4
+ # The character resource.
5
+ class CharacterResource < Resource
6
+ # Get a list of characters.
7
+ # @param params [Hash] the params to pass to the API request.
8
+ # See the [characters documentation from Marvel](https://developer.marvel.com/docs#!/public/getCreatorCollection_get_0)
9
+ # for valid options.
10
+ # @return [Harkness::CharacterDataWrapper] the top level wrapper around the character API response.
11
+ # @example
12
+ # client.characters.list
13
+ # client.characters.list(nameStartsWith: "Ant-", limit: 10, orderBy: "-modified")
14
+ def list(**params)
15
+ CharacterDataWrapper.from_json(get_request("characters", params: params).body)
16
+ end
17
+
18
+ # Get a single character.
19
+ # @param character_id [Integer] the ID of the character.
20
+ # @return [Harkness::CharacterDataWrapper] the top level wrapper around the character API response.
21
+ # @example
22
+ # client.characters.retrieve(character_id: 1234)
23
+ def retrieve(character_id:)
24
+ CharacterDataWrapper.from_json(get_request("characters/#{character_id}").body)
25
+ end
26
+
27
+ # Get a list of comics for a particular character.
28
+ # @param character_id [Integer] the ID of the character.
29
+ # @return [Harkness::ComicDataWrapper] the top level wrapper around the comic API response.
30
+ # @example
31
+ # client.characters.comics(character_id: 1234)
32
+ def comics(character_id:)
33
+ ComicDataWrapper.from_json(get_request("characters/#{character_id}/comics").body)
34
+ end
35
+
36
+ # Get a list of events for a particular character.
37
+ # @param character_id [Integer] the ID of the character.
38
+ # @return [Harkness::EventDataWrapper] the top level wrapper around the event API response.
39
+ # @example
40
+ # client.characters.events(character_id: 1234)
41
+ def events(character_id:)
42
+ EventDataWrapper.from_json(get_request("characters/#{character_id}/events").body)
43
+ end
44
+
45
+ # Get a list of series for a particular character.
46
+ # @param character_id [Integer] the ID of the character.
47
+ # @return [Harkness::SeriesDataWrapper] the top level wrapper around the series API response.
48
+ # @example
49
+ # client.characters.series(character_id: 1234)
50
+ def series(character_id:)
51
+ SeriesDataWrapper.from_json(get_request("characters/#{character_id}/series").body)
52
+ end
53
+
54
+ # Get a list of stories for a particular character.
55
+ # @param character_id [Integer] the ID of the character.
56
+ # @return [Harkness::StoryDataWrapper] the top level wrapper around the story API response.
57
+ # @example
58
+ # client.stories.characters(character_id: 1234)
59
+ def stories(character_id:)
60
+ StoryDataWrapper.from_json(get_request("characters/#{character_id}/stories").body)
61
+ end
62
+ end
63
+ end
@@ -0,0 +1,63 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Harkness
4
+ # The comic resource.
5
+ class ComicResource < Resource
6
+ # Get a list of comics.
7
+ # @param params [Hash] the params to pass to the API request.
8
+ # See the [comics documentation from Marvel](https://developer.marvel.com/docs#!/public/getComicsCollection_get_6)
9
+ # for valid options.
10
+ # @return [Harkness::ComicDataWrapper] the top level wrapper around the comic API response.
11
+ # @example
12
+ # client.comics.list
13
+ # client.comics.list(titleStartsWith: "Spider", limit: 10, orderBy: "issueNumber")
14
+ def list(**params)
15
+ ComicDataWrapper.from_json(get_request("comics", params: params).body)
16
+ end
17
+
18
+ # Get a single comic.
19
+ # @param comic_id [Integer] the ID of the comic.
20
+ # @return [Harkness::ComicDataWrapper] the top level wrapper around the comic API response.
21
+ # @example
22
+ # client.comics.retrieve(comic_id: 1234)
23
+ def retrieve(comic_id:)
24
+ ComicDataWrapper.from_json(get_request("comics/#{comic_id}").body)
25
+ end
26
+
27
+ # Get a list of characters for a particular comic.
28
+ # @param comic_id [Integer] the ID of the comic.
29
+ # @return [Harkness::CharacterDataWrapper] the top level wrapper around the character API response.
30
+ # @example
31
+ # client.comics.characters(comic_id: 1234)
32
+ def characters(comic_id:)
33
+ CharacterDataWrapper.from_json(get_request("comics/#{comic_id}/characters").body)
34
+ end
35
+
36
+ # Get a list of creators for a particular comic.
37
+ # @param comic_id [Integer] the ID of the comic.
38
+ # @return [Harkness::CreatorDataWrapper] the top level wrapper around the creator API response.
39
+ # @example
40
+ # client.comics.creators(comic_id: 1234)
41
+ def creators(comic_id:)
42
+ CreatorDataWrapper.from_json(get_request("comics/#{comic_id}/creators").body)
43
+ end
44
+
45
+ # Get a list of events for a particular comic.
46
+ # @param comic_id [Integer] the ID of the comic.
47
+ # @return [Harkness::EventDataWrapper] the top level wrapper around the event API response.
48
+ # @example
49
+ # client.comics.events(comic_id: 1234)
50
+ def events(comic_id:)
51
+ EventDataWrapper.from_json(get_request("comics/#{comic_id}/events").body)
52
+ end
53
+
54
+ # Get a list of stories for a particular comic.
55
+ # @param comic_id [Integer] the ID of the comic.
56
+ # @return [Harkness::StoryDataWrapper] the top level wrapper around the story API response.
57
+ # @example
58
+ # client.comics.stories(comic_id: 1234)
59
+ def stories(comic_id:)
60
+ StoryDataWrapper.from_json(get_request("comics/#{comic_id}/stories").body)
61
+ end
62
+ end
63
+ end
@@ -0,0 +1,63 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Harkness
4
+ # The creator resource.
5
+ class CreatorResource < Resource
6
+ # Get a list of creators.
7
+ # @param params [Hash] the params to pass to the API request.
8
+ # See the [creators documentation from Marvel](https://developer.marvel.com/docs#!/public/getCreatorCollection_get_12)
9
+ # for valid options.
10
+ # @return [Harkness::CreatorDataWrapper] the top level wrapper around the creator API response.
11
+ # @example
12
+ # client.creators.list
13
+ # client.creators.list(firstNameStartsWith: "Ben", limit: 10, orderBy: "lastName")
14
+ def list(**params)
15
+ CreatorDataWrapper.from_json(get_request("creators", params: params).body)
16
+ end
17
+
18
+ # Get a single creator.
19
+ # @param creator_id [Integer] the ID of the creator.
20
+ # @return [Harkness::CreatorDataWrapper] the top level wrapper around the creator API response.
21
+ # @example
22
+ # client.creators.retrieve(creator_id: 1234)
23
+ def retrieve(creator_id:)
24
+ CreatorDataWrapper.from_json(get_request("creators/#{creator_id}").body)
25
+ end
26
+
27
+ # Get a list of comics for a particular creator.
28
+ # @param creator_id [Integer] the ID of the creator.
29
+ # @return [Harkness::ComicDataWrapper] the top level wrapper around the comic API response.
30
+ # @example
31
+ # client.creators.comics(creator_id: 1234)
32
+ def comics(creator_id:)
33
+ ComicDataWrapper.from_json(get_request("creators/#{creator_id}/comics").body)
34
+ end
35
+
36
+ # Get a list of events for a particular creator.
37
+ # @param creator_id [Integer] the ID of the creator.
38
+ # @return [Harkness::EventDataWrapper] the top level wrapper around the event API response.
39
+ # @example
40
+ # client.creators.events(creator_id: 1234)
41
+ def events(creator_id:)
42
+ EventDataWrapper.from_json(get_request("creators/#{creator_id}/events").body)
43
+ end
44
+
45
+ # Get a list of series for a particular creator.
46
+ # @param creator_id [Integer] the ID of the creator.
47
+ # @return [Harkness::SeriesDataWrapper] the top level wrapper around the series API response.
48
+ # @example
49
+ # client.creators.series(creator_id: 1234)
50
+ def series(creator_id:)
51
+ SeriesDataWrapper.from_json(get_request("creators/#{creator_id}/series").body)
52
+ end
53
+
54
+ # Get a list of stories for a particular creator.
55
+ # @param creator_id [Integer] the ID of the creator.
56
+ # @return [Harkness::StoryDataWrapper] the top level wrapper around the story API response.
57
+ # @example
58
+ # client.creators.stories(creator_id: 1234)
59
+ def stories(creator_id:)
60
+ StoryDataWrapper.from_json(get_request("creators/#{creator_id}/stories").body)
61
+ end
62
+ end
63
+ end