harkness 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +13 -0
- data/README.md +1 -1
- data/lib/harkness/error.rb +1 -0
- data/lib/harkness/models/base/data_container.rb +4 -4
- data/lib/harkness/models/base/data_wrapper.rb +11 -11
- data/lib/harkness/models/base/summary.rb +2 -2
- data/lib/harkness/models/character.rb +14 -14
- data/lib/harkness/models/character_list.rb +7 -7
- data/lib/harkness/models/comic.rb +80 -0
- data/lib/harkness/models/comic_list.rb +12 -0
- data/lib/harkness/models/creator.rb +35 -0
- data/lib/harkness/models/creator_list.rb +13 -0
- data/lib/harkness/models/event_list.rb +12 -0
- data/lib/harkness/models/image.rb +4 -0
- data/lib/harkness/models/series.rb +41 -1
- data/lib/harkness/models/series_list.rb +12 -0
- data/lib/harkness/models/story.rb +32 -0
- data/lib/harkness/models/story_list.rb +14 -0
- data/lib/harkness/models/text_object.rb +7 -1
- data/lib/harkness/models/url.rb +4 -0
- data/lib/harkness/resource.rb +18 -0
- data/lib/harkness/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 306a55aff7abd2df10be5d952209fddbfd66125d4928c2b857fab9a78a89225d
|
4
|
+
data.tar.gz: 47a9be14d3e650d34129548872e36eeaa2696026a57e67ac10099ec7833c180a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7a5b6517f178ba753effdbe164cbb881c7d6b8246055c6d05eba6e3a74fca02caf2036e836fa3502cd9b9b79082a03e8bff24fe7e7b4dfbb75f71a33eccb395b
|
7
|
+
data.tar.gz: 0eaadb16b2961eee7eac183dcb7455e5a663bf3552db57395e295ace79e28024dfc9a44f9f586fa406f3a1819c2873636a18cff8edfafa0b2c7a322b679f218f
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,18 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## [1.1.0](https://github.com/duffn/harkness/compare/v1.0.0...v1.1.0) (2023-03-13)
|
4
|
+
|
5
|
+
|
6
|
+
### Features
|
7
|
+
|
8
|
+
* Add additional code docs ([#7](https://github.com/duffn/harkness/issues/7)) ([8fead00](https://github.com/duffn/harkness/commit/8fead007d888b79bcd6e54afd8705dafea390a16))
|
9
|
+
* Add yard docs for Comic, ComicList, and related classes ([ab12e30](https://github.com/duffn/harkness/commit/ab12e300cee37c32e0a55b1198bb866518b53643))
|
10
|
+
|
11
|
+
|
12
|
+
### Bug Fixes
|
13
|
+
|
14
|
+
* add missing `returned` attribute for some summary models ([#5](https://github.com/duffn/harkness/issues/5)) ([2339e9c](https://github.com/duffn/harkness/commit/2339e9c20be0860640970a9701437e98f0b60f66))
|
15
|
+
|
3
16
|
## [1.0.0] (2023-03-12)
|
4
17
|
|
5
18
|
- Initial release
|
data/README.md
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
A full-featured and painstakingly documented library for working (playing) with the [Marvel API](https://developer.marvel.com/docs).
|
4
4
|
|
5
|
-
![main](https://github.com/duffn/harkness/actions/workflows/test.yml/badge.svg) [![codecov](https://codecov.io/gh/duffn/harkness/branch/main/graph/badge.svg?token=9XUA33QIM2)](https://codecov.io/gh/duffn/harkness)
|
5
|
+
![main](https://github.com/duffn/harkness/actions/workflows/test.yml/badge.svg) [![codecov](https://codecov.io/gh/duffn/harkness/branch/main/graph/badge.svg?token=9XUA33QIM2)](https://codecov.io/gh/duffn/harkness) [![Gem Version](https://badge.fury.io/rb/harkness.svg)](https://badge.fury.io/rb/harkness)
|
6
6
|
|
7
7
|
## Installation
|
8
8
|
|
data/lib/harkness/error.rb
CHANGED
@@ -5,16 +5,16 @@ module Harkness
|
|
5
5
|
# Container class that holds pagination information.
|
6
6
|
class DataContainer < Shale::Mapper
|
7
7
|
# @!attribute [r] offset
|
8
|
-
#
|
8
|
+
# @return [Integer] the requested offset (number of skipped results) of the call.
|
9
9
|
attribute :offset, Shale::Type::Integer
|
10
10
|
# @!attribute [r] limit
|
11
|
-
#
|
11
|
+
# @return [Integer] the requested result limit.
|
12
12
|
attribute :limit, Shale::Type::Integer
|
13
13
|
# @!attribute [r] total
|
14
|
-
#
|
14
|
+
# @return [Integer] the total number of resources available given the current filter set.
|
15
15
|
attribute :total, Shale::Type::Integer
|
16
16
|
# @!attribute [r] count
|
17
|
-
#
|
17
|
+
# @return [Integer] the total number of results returned by this call.
|
18
18
|
attribute :count, Shale::Type::Integer
|
19
19
|
end
|
20
20
|
end
|
@@ -5,29 +5,29 @@ module Harkness
|
|
5
5
|
# The top level wrapper of a response from the API.
|
6
6
|
class DataWrapper < Shale::Mapper
|
7
7
|
# @!attribute [r] code
|
8
|
-
#
|
8
|
+
# @return [Integer] the HTTP status code of the returned result.
|
9
9
|
attribute :code, Shale::Type::Integer
|
10
10
|
# @!attribute [r] status
|
11
|
-
#
|
11
|
+
# @return [String] a string description of the call status.
|
12
12
|
attribute :status, Shale::Type::String
|
13
13
|
# @!attribute [r] copyright
|
14
|
-
#
|
14
|
+
# @return [String] the copyright notice for the returned result.
|
15
15
|
attribute :copyright, Shale::Type::String
|
16
16
|
# @!attribute [r] attributionText
|
17
|
-
#
|
18
|
-
#
|
19
|
-
#
|
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
20
|
attribute :attributionText, Shale::Type::String
|
21
21
|
# @!attribute [r] attributionHTML
|
22
|
-
#
|
23
|
-
#
|
24
|
-
#
|
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
25
|
attribute :attributionHTML, Shale::Type::String
|
26
26
|
# @!attribute [r] data
|
27
|
-
#
|
27
|
+
# @return [Harkness::Base::DataContainer] the results returned by the call.
|
28
28
|
attribute :data, Harkness::Base::DataContainer
|
29
29
|
# @!attribute [r] etag
|
30
|
-
#
|
30
|
+
# @return [String] a digest value of the content returned by the call.
|
31
31
|
attribute :etag, Shale::Type::String
|
32
32
|
end
|
33
33
|
end
|
@@ -7,10 +7,10 @@ module Harkness
|
|
7
7
|
# one of the summary objects is a Series.
|
8
8
|
class Summary < Shale::Mapper
|
9
9
|
# @!attribute [r] resourceURI
|
10
|
-
#
|
10
|
+
# @return [String] the path to the individual resource.
|
11
11
|
attribute :resourceURI, Shale::Type::String
|
12
12
|
# @!attribute [r] name
|
13
|
-
#
|
13
|
+
# @return [String] the canonical name of the resource.
|
14
14
|
attribute :name, Shale::Type::String
|
15
15
|
end
|
16
16
|
end
|
@@ -4,51 +4,51 @@ module Harkness
|
|
4
4
|
# An individual character.
|
5
5
|
class Character < Shale::Mapper
|
6
6
|
# @!attribute [r] id
|
7
|
-
#
|
7
|
+
# @return [Integer] the unique ID of the character resource.
|
8
8
|
attribute :id, Shale::Type::Integer
|
9
9
|
# @!attribute [r] name
|
10
|
-
#
|
10
|
+
# @return [String] the name of the character.
|
11
11
|
attribute :name, Shale::Type::String
|
12
12
|
# @!attribute [r] description
|
13
|
-
#
|
13
|
+
# @return [String] a short bio or description of the character
|
14
14
|
attribute :description, Shale::Type::String
|
15
15
|
# @!attribute [r] modified
|
16
|
-
#
|
16
|
+
# @return [String] the date the resource was most recently modified.
|
17
17
|
attribute :modified, Shale::Type::String
|
18
18
|
# @!attribute [r] resourceURI
|
19
|
-
#
|
19
|
+
# @return [String] the canonical URL identifier for this resource.
|
20
20
|
attribute :resourceURI, Shale::Type::String
|
21
21
|
# @!attribute [r] urls
|
22
|
-
#
|
22
|
+
# @return [Array<Harkness::URL>] a set of public web site URLs for the resource.
|
23
23
|
attribute :urls, Harkness::URL, collection: true
|
24
24
|
# @!attribute [r] thumbnail
|
25
|
-
#
|
25
|
+
# @return [Harkness::Image] the representative image for this character.
|
26
26
|
attribute :thumbnail, Harkness::Image
|
27
27
|
# @!attribute [r] comics
|
28
|
-
#
|
28
|
+
# @return [Harkness::ComicList] a resource list containing comics which feature this character.
|
29
29
|
attribute :comics, Harkness::ComicList
|
30
30
|
# @!attribute [r] stories
|
31
|
-
#
|
31
|
+
# @return [Harkness::StoryList] a resource list of stories in which this character appears.
|
32
32
|
attribute :stories, Harkness::StoryList
|
33
33
|
# @!attribute [r] events
|
34
|
-
#
|
34
|
+
# @return [Harkness::EventList] a resource list of events in which this character appears.
|
35
35
|
attribute :events, Harkness::EventList
|
36
36
|
# @!attribute [r] series
|
37
|
-
#
|
37
|
+
# @return [Harkness::SeriesList] a resource list of series in which this character appears.
|
38
38
|
attribute :series, Harkness::SeriesList
|
39
39
|
end
|
40
40
|
|
41
|
-
# Container class that holds pagination information and results
|
41
|
+
# Container class that holds pagination information and results.
|
42
42
|
class CharacterDataContainer < Harkness::Base::DataContainer
|
43
43
|
# @!attribute [r] results
|
44
|
-
#
|
44
|
+
# @return [Array<Harkness::Character>] the list of characters returned by the call.
|
45
45
|
attribute :results, Harkness::Character, collection: true
|
46
46
|
end
|
47
47
|
|
48
48
|
# The top level wrapper of a response from the API.
|
49
49
|
class CharacterDataWrapper < Harkness::Base::DataWrapper
|
50
50
|
# @!attribute [r] data
|
51
|
-
#
|
51
|
+
# @return [Harkness::CharacterDataContainer] the results returned by the call.
|
52
52
|
attribute :data, Harkness::CharacterDataContainer
|
53
53
|
end
|
54
54
|
end
|
@@ -4,24 +4,24 @@ module Harkness
|
|
4
4
|
# The summary of a character.
|
5
5
|
class CharacterSummary < Harkness::Base::Summary
|
6
6
|
# @!attribute [r] role
|
7
|
-
#
|
7
|
+
# @return [String] the role of the character in the parent entity.
|
8
8
|
attribute :role, Shale::Type::String
|
9
9
|
end
|
10
10
|
|
11
11
|
# A list of characters.
|
12
12
|
class CharacterList < Shale::Mapper
|
13
13
|
# @!attribute [r] available
|
14
|
-
#
|
15
|
-
#
|
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
16
|
attribute :available, Shale::Type::Integer
|
17
17
|
# @!attribute [r] returned
|
18
|
-
#
|
18
|
+
# @return [Integer] the number of characters returned in this collection (up to 20).
|
19
19
|
attribute :returned, Shale::Type::Integer
|
20
20
|
# @!attribute [r] collectionURI
|
21
|
-
#
|
21
|
+
# @return [String] the path to the full list of characters in this collection.
|
22
22
|
attribute :collectionURI, Shale::Type::String
|
23
|
-
# @!attribute [r]
|
24
|
-
#
|
23
|
+
# @!attribute [r] items
|
24
|
+
# @return [Array<Harkness::CharacterSummary>] the list of returned characters in this collection.
|
25
25
|
attribute :items, Harkness::CharacterSummary, collection: true
|
26
26
|
end
|
27
27
|
end
|
@@ -1,53 +1,133 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Harkness
|
4
|
+
# The data of a comic.
|
4
5
|
class ComicDate < Shale::Mapper
|
6
|
+
# @!attribute [r] type
|
7
|
+
# @return [String] a description of the date (e.g. onsale date, FOC date).
|
5
8
|
attribute :type, Shale::Type::String
|
9
|
+
# @!attribute [r] date
|
10
|
+
# @return [String] the date.
|
6
11
|
attribute :date, Shale::Type::String
|
7
12
|
end
|
8
13
|
|
14
|
+
# The price of a comic.
|
9
15
|
class ComicPrice < Shale::Mapper
|
16
|
+
# @!attribute [r] type
|
17
|
+
# @return [String] a description of the price (e.g. print price, digital price).
|
10
18
|
attribute :type, Shale::Type::String
|
19
|
+
# @!attribute [r] price
|
20
|
+
# @return [Float] the price (all prices in USD).
|
11
21
|
attribute :price, Shale::Type::Float
|
12
22
|
end
|
13
23
|
|
24
|
+
# An individual character.
|
14
25
|
class Comic < Shale::Mapper
|
26
|
+
# @!attribute [r] id
|
27
|
+
# @return [Integer] the unique ID of the comic resource.
|
15
28
|
attribute :id, Shale::Type::Integer
|
29
|
+
# @!attribute [r] digitalId
|
30
|
+
# @return [Integer] the ID of the digital comic representation of this comic. Will be 0 if the comic is
|
31
|
+
# not available digitally.
|
16
32
|
attribute :digitalId, Shale::Type::Integer
|
33
|
+
# @!attribute [r] title
|
34
|
+
# @return [String] the canonical title of the comic.
|
17
35
|
attribute :title, Shale::Type::String
|
36
|
+
# @!attribute [r] issueNumber
|
37
|
+
# @return [Integer] the number of the issue in the series (will generally be 0 for collection formats).
|
18
38
|
attribute :issueNumber, Shale::Type::Integer
|
39
|
+
# @!attribute [r] variantDescription
|
40
|
+
# @return [String] If the issue is a variant (e.g. an alternate cover, second printing, or director’s cut),
|
41
|
+
# a text description of the variant.
|
19
42
|
attribute :variantDescription, Shale::Type::String
|
43
|
+
# @!attribute [r] description
|
44
|
+
# @return [String] the preferred description of the comic.
|
20
45
|
attribute :description, Shale::Type::String
|
46
|
+
# @!attribute [r] modified
|
47
|
+
# @return [String] the date the resource was most recently modified.
|
21
48
|
attribute :modified, Shale::Type::String
|
49
|
+
# @!attribute [r] isbn
|
50
|
+
# @return [String] the ISBN for the comic (generally only populated for collection formats).
|
22
51
|
attribute :isbn, Shale::Type::String
|
52
|
+
# @!attribute [r] upc
|
53
|
+
# @return [String] the UPC barcode number for the comic (generally only populated for periodical formats).
|
23
54
|
attribute :upc, Shale::Type::String
|
55
|
+
# @!attribute [r] diamondCode
|
56
|
+
# @return [String] the Diamond code for the comic.
|
24
57
|
attribute :diamondCode, Shale::Type::String
|
58
|
+
# @!attribute [r] ean
|
59
|
+
# @return [String] the EAN barcode for the comic.
|
25
60
|
attribute :ean, Shale::Type::String
|
61
|
+
# @!attribute [r] issn
|
62
|
+
# @return [String] the ISSN barcode for the comic.
|
26
63
|
attribute :issn, Shale::Type::String
|
64
|
+
# @!attribute [r] format
|
65
|
+
# @return [String] the publication format of the comic e.g. comic, hardcover, trade paperback.
|
27
66
|
attribute :format, Shale::Type::String
|
67
|
+
# @!attribute [r] pageCount
|
68
|
+
# @return [Integer] the number of story pages in the comic.
|
28
69
|
attribute :pageCount, Shale::Type::Integer
|
70
|
+
# @!attribute [r] textObjects
|
71
|
+
# @return [Array<Harkness::TextObject>] a set of descriptive text blurbs for the comic.
|
29
72
|
attribute :textObjects, Harkness::TextObject, collection: true
|
73
|
+
# @!attribute [r] resourceURI
|
74
|
+
# @return [String] the canonical URL identifier for this resource.
|
30
75
|
attribute :resourceURI, Shale::Type::String
|
76
|
+
# @!attribute [r] urls
|
77
|
+
# @return [Array<Harkness::URL>] a set of public web site URLs for the resource.
|
31
78
|
attribute :urls, Harkness::URL, collection: true
|
79
|
+
# @!attribute [r] series
|
80
|
+
# @return [Array<Harkness::SeriesSummary>] a summary representation of the series to which this comic belongs.
|
32
81
|
attribute :series, Harkness::SeriesSummary
|
82
|
+
# @!attribute [r] variants
|
83
|
+
# @return [Array<Harkness::ComicSummary>] a list of variant issues for this comic (includes the "original" issue
|
84
|
+
# if the current issue is a variant).
|
33
85
|
attribute :variants, Harkness::ComicSummary, collection: true
|
86
|
+
# @!attribute [r] collections
|
87
|
+
# @return [Array<Harkness::ComicSummary>] A list of collections which include this comic (will generally
|
88
|
+
# be empty if the comic's format is a collection).
|
34
89
|
attribute :collections, Harkness::ComicSummary, collection: true
|
90
|
+
# @!attribute [r] collectedIssues
|
91
|
+
# @return [Array<Harkness::ComicSummary>] a list of issues collected in this comic (will generally
|
92
|
+
# be empty for periodical formats such as "comic" or "magazine").
|
35
93
|
attribute :collectedIssues, Harkness::ComicSummary, collection: true
|
94
|
+
# @!attribute [r] dates
|
95
|
+
# @return [Array<Harkness::ComicDate] a list of key dates for this comic.
|
36
96
|
attribute :dates, Harkness::ComicDate, collection: true
|
97
|
+
# @!attribute [r] prices
|
98
|
+
# @return [Array<Harkness::ComicPrice>] a list of prices for this comic.
|
37
99
|
attribute :prices, Harkness::ComicPrice, collection: true
|
100
|
+
# @!attribute [r] thumbnail
|
101
|
+
# @return [Harkness::Image] the representative image for this comic.
|
38
102
|
attribute :thumbnail, Harkness::Image
|
103
|
+
# @!attribute [r] images
|
104
|
+
# @return [Array<Harkness::Image>] a list of promotional images associated with this comic.
|
39
105
|
attribute :images, Harkness::Image, collection: true
|
106
|
+
# @!attribute [r] creators
|
107
|
+
# @return [Harkness::CreatorList] a resource list containing the creators associated with this comic.
|
40
108
|
attribute :creators, Harkness::CreatorList
|
109
|
+
# @!attribute [r] characters
|
110
|
+
# @return [Harkness::CharacterList] a resource list containing the characters which appear in this comic.
|
41
111
|
attribute :characters, Harkness::CharacterList
|
112
|
+
# @!attribute [r] stories
|
113
|
+
# @return [Harkness::StoryList] a resource list containing the stories which appear in this comic.
|
42
114
|
attribute :stories, Harkness::StoryList
|
115
|
+
# @!attribute [r] events
|
116
|
+
# @return [Harkness::EventList] a resource list containing the events in which this comic appears.
|
43
117
|
attribute :events, Harkness::EventList
|
44
118
|
end
|
45
119
|
|
120
|
+
# Container class that holds pagination information and results.
|
46
121
|
class ComicDataContainer < Harkness::Base::DataContainer
|
122
|
+
# @!attribute [r] results
|
123
|
+
# @return [Array<Harkness::Comic>] the list of comics returned by the call.
|
47
124
|
attribute :results, Harkness::Comic, collection: true
|
48
125
|
end
|
49
126
|
|
127
|
+
# The top level wrapper of a response from the API.
|
50
128
|
class ComicDataWrapper < Harkness::Base::DataWrapper
|
129
|
+
# @!attribute [r] data
|
130
|
+
# @return [Harkness::ComicDataContainer] The results returned by the call.
|
51
131
|
attribute :data, Harkness::ComicDataContainer
|
52
132
|
end
|
53
133
|
end
|
@@ -1,12 +1,24 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Harkness
|
4
|
+
# The summary of a comic.
|
4
5
|
class ComicSummary < Harkness::Base::Summary
|
5
6
|
end
|
6
7
|
|
8
|
+
# A list of comics.
|
7
9
|
class ComicList < Shale::Mapper
|
10
|
+
# @!attribute [r] available
|
11
|
+
# @return [Integer] the number of total available issues in this list. Will always be greater than
|
12
|
+
# or equal to the "returned" value.
|
8
13
|
attribute :available, Shale::Type::Integer
|
14
|
+
# @!attribute [r] returned
|
15
|
+
# @return [Integer] the number of comics returned in this collection (up to 20).
|
16
|
+
attribute :returned, Shale::Type::Integer
|
17
|
+
# @!attribute [r] collectionURI
|
18
|
+
# @return [String] the path to the full list of issues in this collection.
|
9
19
|
attribute :collectionURI, Shale::Type::String
|
20
|
+
# @!attribute [r] collectionURI
|
21
|
+
# @return [Array<Harkness::ComicSummary>] the list of returned issues in this collection.
|
10
22
|
attribute :items, Harkness::ComicSummary, collection: true
|
11
23
|
end
|
12
24
|
end
|
@@ -1,28 +1,63 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Harkness
|
4
|
+
# An individual creator.
|
4
5
|
class Creator < Shale::Mapper
|
6
|
+
# @!attribute [r] id
|
7
|
+
# @return [Integer] the unique ID of the creator resource.
|
5
8
|
attribute :id, Shale::Type::Integer
|
9
|
+
# @!attribute [r] firstName
|
10
|
+
# @return [String] the first name of the creator.
|
6
11
|
attribute :firstName, Shale::Type::String
|
12
|
+
# @!attribute [r] middleName
|
13
|
+
# @return [String] the middle name of the creator.
|
7
14
|
attribute :middleName, Shale::Type::String
|
15
|
+
# @!attribute [r] lastName
|
16
|
+
# @return [String] tThe last name of the creator.
|
8
17
|
attribute :lastName, Shale::Type::String
|
18
|
+
# @!attribute [r] suffix
|
19
|
+
# @return [String] the suffix or honorific for the creator.
|
9
20
|
attribute :suffix, Shale::Type::String
|
21
|
+
# @!attribute [r] fullName
|
22
|
+
# @return [String] the full name of the creator (a space-separated concatenation of the above four fields).
|
10
23
|
attribute :fullName, Shale::Type::String
|
24
|
+
# @!attribute [r] modified
|
25
|
+
# @return [String] the date the resource was most recently modified.
|
11
26
|
attribute :modified, Shale::Type::String
|
27
|
+
# @!attribute [r] resourceURI
|
28
|
+
# @return [String] the canonical URL identifier for this resource.
|
12
29
|
attribute :resourceURI, Shale::Type::String
|
30
|
+
# @!attribute [r] urls
|
31
|
+
# @return [Array<Harkness::URL>] a set of public web site URLs for the resource.
|
13
32
|
attribute :urls, Harkness::URL, collection: true
|
33
|
+
# @!attribute [r] thumbnail
|
34
|
+
# @return [Harkness::Image] the representative image for this creator.
|
14
35
|
attribute :thumbnail, Harkness::Image
|
36
|
+
# @!attribute [r] series
|
37
|
+
# @return [Harkness::SeriesList] a resource list containing the series which feature work by this creator
|
15
38
|
attribute :series, Harkness::SeriesList
|
39
|
+
# @!attribute [r] stories
|
40
|
+
# @return [Harkness::StoryList] A resource list containing the stories which feature work by this creator.
|
16
41
|
attribute :stories, Harkness::StoryList
|
42
|
+
# @!attribute [r] comics
|
43
|
+
# @return [Harkness::ComicList] a resource list containing the comics which feature work by this creator.
|
17
44
|
attribute :comics, Harkness::ComicList
|
45
|
+
# @!attribute [r] events
|
46
|
+
# @return [Harkness::EventList] a resource list containing the events which feature work by this creator.
|
18
47
|
attribute :events, Harkness::EventList
|
19
48
|
end
|
20
49
|
|
50
|
+
# Container class that holds pagination information and results.
|
21
51
|
class CreatorDataContainer < Harkness::Base::DataContainer
|
52
|
+
# @!attribute [r] results
|
53
|
+
# @return [Array<Harkness::Creator>] the list of creators returned by the call.
|
22
54
|
attribute :results, Harkness::Creator, collection: true
|
23
55
|
end
|
24
56
|
|
57
|
+
# The top level wrapper of a response from the API.
|
25
58
|
class CreatorDataWrapper < Harkness::Base::DataWrapper
|
59
|
+
# @!attribute [r] data
|
60
|
+
# @return [Harkness::CreatorDataContainer] the results returned by the call.
|
26
61
|
attribute :data, Harkness::CreatorDataContainer
|
27
62
|
end
|
28
63
|
end
|
@@ -1,14 +1,27 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Harkness
|
4
|
+
# The summary of a creator.
|
4
5
|
class CreatorSummary < Harkness::Base::Summary
|
6
|
+
# @!attribute [r] role
|
7
|
+
# @return [String] the role of the creator in the parent entity.
|
5
8
|
attribute :role, Shale::Type::String
|
6
9
|
end
|
7
10
|
|
11
|
+
# A list of creators.
|
8
12
|
class CreatorList < Shale::Mapper
|
13
|
+
# @!attribute [r] available
|
14
|
+
# @return [Integer] the number of total available creators in this list.
|
15
|
+
# Will always be greater than or equal to the "returned" value.
|
9
16
|
attribute :available, Shale::Type::Integer
|
17
|
+
# @!attribute [r] returned
|
18
|
+
# @return [Integer] the number of creators returned in this collection (up to 20).
|
10
19
|
attribute :returned, Shale::Type::Integer
|
20
|
+
# @!attribute [r] collectionURI
|
21
|
+
# @return [String] the path to the full list of creators in this collection.
|
11
22
|
attribute :collectionURI, Shale::Type::String
|
23
|
+
# @!attribute [r] offset
|
24
|
+
# @return [Array<Harkness::CreatorySummary>] the list of returned creators in this collection.
|
12
25
|
attribute :items, Harkness::CreatorSummary, collection: true
|
13
26
|
end
|
14
27
|
end
|
@@ -1,12 +1,24 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Harkness
|
4
|
+
# The summary of an event.
|
4
5
|
class EventSummary < Harkness::Base::Summary
|
5
6
|
end
|
6
7
|
|
8
|
+
# A list of events.
|
7
9
|
class EventList < Shale::Mapper
|
10
|
+
# @!attribute [r] available
|
11
|
+
# @return [Integer] the number of total available events in this list.
|
12
|
+
# Will always be greater than or equal to the "returned" value.
|
8
13
|
attribute :available, Shale::Type::Integer
|
14
|
+
# @!attribute [r] returned
|
15
|
+
# @return [Integer] the number of events returned in this collection (up to 20).
|
16
|
+
attribute :returned, Shale::Type::Integer
|
17
|
+
# @!attribute [r] collectionURI
|
18
|
+
# @return [String] the path to the full list of events in this collection.
|
9
19
|
attribute :collectionURI, Shale::Type::String
|
20
|
+
# @!attribute [r] items
|
21
|
+
# @return [Array<Harkness::EventSummary>] the list of returned characters in this collection.
|
10
22
|
attribute :items, Harkness::EventSummary, collection: true
|
11
23
|
end
|
12
24
|
end
|
@@ -3,7 +3,11 @@
|
|
3
3
|
module Harkness
|
4
4
|
# An image.
|
5
5
|
class Image < Shale::Mapper
|
6
|
+
# @!attribute [r] path
|
7
|
+
# @return [String] the directory path of to the image.,
|
6
8
|
attribute :path, Shale::Type::String
|
9
|
+
# @!attribute [r] extension
|
10
|
+
# @return [String] the file extension for the image.
|
7
11
|
attribute :extension, Shale::Type::String
|
8
12
|
end
|
9
13
|
end
|
@@ -1,32 +1,72 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Harkness
|
4
|
+
# An individual series.
|
4
5
|
class Series < Shale::Mapper
|
6
|
+
# @!attribute [r] id
|
7
|
+
# @return [Integer] the unique ID of the series resource.
|
5
8
|
attribute :id, Shale::Type::Integer
|
9
|
+
# @!attribute [r] title
|
10
|
+
# @return [String] the canonical title of the series.
|
6
11
|
attribute :title, Shale::Type::String
|
12
|
+
# @!attribute [r] description
|
13
|
+
# @return [String] a description of the series.
|
7
14
|
attribute :description, Shale::Type::String
|
15
|
+
# @!attribute [r] resourceURI
|
16
|
+
# @return [String] the canonical URL identifier for this resource.
|
8
17
|
attribute :resourceURI, Shale::Type::String
|
18
|
+
# @!attribute [r] urls
|
19
|
+
# @return [Array<Harkness::URL>] a set of public web site URLs for the resource.
|
9
20
|
attribute :urls, Harkness::URL, collection: true
|
10
|
-
|
21
|
+
# @!attribute [r] startYear
|
22
|
+
# @return [Integer] the first year of publication for the series.
|
11
23
|
attribute :startYear, Shale::Type::Integer
|
24
|
+
# @!attribute [r] endYear
|
25
|
+
# @return [Integer] the last year of publication for the series (conventionally, 2099 for ongoing series).
|
12
26
|
attribute :endYear, Shale::Type::Integer
|
27
|
+
# @!attribute [r] rating
|
28
|
+
# @return [String] the age-appropriateness rating for the series.
|
13
29
|
attribute :rating, Shale::Type::String
|
30
|
+
# @!attribute [r] modified
|
31
|
+
# @return [String] the date the resource was most recently modified.
|
14
32
|
attribute :modified, Shale::Type::String
|
33
|
+
# @!attribute [r] thumbnail
|
34
|
+
# @return [Harkness::Image] the representative image for this SERIES.
|
15
35
|
attribute :thumbnail, Harkness::Image
|
36
|
+
# @!attribute [r] comics
|
37
|
+
# @return [Harkness::ComicList] : a resource list containing comics in this series.
|
16
38
|
attribute :comics, Harkness::ComicList
|
39
|
+
# @!attribute [r] stories
|
40
|
+
# @return [Harkness::StoryList] a resource list containing stories which occur in comics in this series.
|
17
41
|
attribute :stories, Harkness::StoryList
|
42
|
+
# @!attribute [r] events
|
43
|
+
# @return [Harkness::EventList] a resource list containing events which take place in comics in this series.
|
18
44
|
attribute :events, Harkness::EventList
|
45
|
+
# @!attribute [r] characters
|
46
|
+
# @return [Harkness::CharacterList] a resource list containing characters which appear in comics in this series.
|
19
47
|
attribute :characters, Harkness::CharacterList
|
48
|
+
# @!attribute [r] creators
|
49
|
+
# @return [Harkness::CreatorList] a resource list of creators whose work appears in comics in this series.
|
20
50
|
attribute :creators, Harkness::CreatorList
|
51
|
+
# @!attribute [r] next
|
52
|
+
# @return [Harkness::SeriesSummary] a summary representation of the series which follows this series.,
|
21
53
|
attribute :next, Harkness::SeriesSummary
|
54
|
+
# @!attribute [r] next
|
55
|
+
# @return [Harkness::SeriesSummary] a summary representation of the series which preceded this series.
|
22
56
|
attribute :previous, Harkness::SeriesSummary
|
23
57
|
end
|
24
58
|
|
59
|
+
# Container class that holds pagination information and results.
|
25
60
|
class SeriesDataContainer < Harkness::Base::DataContainer
|
61
|
+
# @!attribute [r] results
|
62
|
+
# @return [Array<Harkness::Series>] the list of series returned by the call.
|
26
63
|
attribute :results, Harkness::Series, collection: true
|
27
64
|
end
|
28
65
|
|
66
|
+
# The top level wrapper of a response from the API.
|
29
67
|
class SeriesDataWrapper < Harkness::Base::DataWrapper
|
68
|
+
# @!attribute [r] data
|
69
|
+
# @return [Harkness::SeriesDataContainer] the results returned by the call.
|
30
70
|
attribute :data, Harkness::SeriesDataContainer
|
31
71
|
end
|
32
72
|
end
|
@@ -1,12 +1,24 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Harkness
|
4
|
+
# The summary of a series.
|
4
5
|
class SeriesSummary < Harkness::Base::Summary
|
5
6
|
end
|
6
7
|
|
8
|
+
# A list of series.
|
7
9
|
class SeriesList < Shale::Mapper
|
10
|
+
# @!attribute [r] available
|
11
|
+
# @return [Integer] the number of total available series in this list.
|
12
|
+
# Will always be greater than or equal to the "returned" value.
|
8
13
|
attribute :available, Shale::Type::Integer
|
14
|
+
# @!attribute [r] returned
|
15
|
+
# @return [Integer] the number of series returned in this collection (up to 20).
|
16
|
+
attribute :returned, Shale::Type::Integer
|
17
|
+
# @!attribute [r] collectionURI
|
18
|
+
# @return [String] the path to the full list of series in this collection.
|
9
19
|
attribute :collectionURI, Shale::Type::String
|
20
|
+
# @!attribute [r] items
|
21
|
+
# @return [Array<Harkness::SeriesSummary>] the list of returned characters in this collection.
|
10
22
|
attribute :items, Harkness::SeriesSummary, collection: true
|
11
23
|
end
|
12
24
|
end
|
@@ -1,26 +1,58 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Harkness
|
4
|
+
# An individual story
|
4
5
|
class Story < Shale::Mapper
|
6
|
+
# @!attribute [r] id
|
7
|
+
# @return [Integer] the unique ID of the story resource.
|
5
8
|
attribute :id, Shale::Type::Integer
|
9
|
+
# @!attribute [r] title
|
10
|
+
# @return [String] the canonical title of the story.
|
6
11
|
attribute :title, Shale::Type::String
|
12
|
+
# @!attribute [r] description
|
13
|
+
# @return [String] a description of the story.
|
7
14
|
attribute :description, Shale::Type::String
|
15
|
+
# @!attribute [r] resourceURI
|
16
|
+
# @return [String] the canonical URL identifier for this resource.
|
8
17
|
attribute :resourceURI, Shale::Type::String
|
18
|
+
# @!attribute [r] type
|
19
|
+
# @return [String] ' the story type e.g. interior story, cover, text story.
|
9
20
|
attribute :type, Shale::Type::String
|
21
|
+
# @!attribute [r] modified
|
22
|
+
# @return [String] the date the resource was most recently modified.
|
10
23
|
attribute :modified, Shale::Type::String
|
24
|
+
# @!attribute [r] thumbnail
|
25
|
+
# @return [String] the representative image for this story.
|
11
26
|
attribute :thumbnail, Harkness::Image
|
27
|
+
# @!attribute [r] comics
|
28
|
+
# @return [Harkness::ComicList] a resource list containing comics in which this story takes place.
|
12
29
|
attribute :comics, Harkness::ComicList
|
30
|
+
# @!attribute [r] series
|
31
|
+
# @return [Harkness::SeriesList] a resource list containing series in which this story appears.
|
13
32
|
attribute :series, Harkness::SeriesList
|
33
|
+
# @!attribute [r] events
|
34
|
+
# @return [Harkness::EventList] a resource list of the events in which this story appears.
|
14
35
|
attribute :events, Harkness::EventList
|
36
|
+
# @!attribute [r] characters
|
37
|
+
# @return [Harkness::CharacterList] a resource list of characters which appear in this story.
|
15
38
|
attribute :characters, Harkness::CharacterList
|
39
|
+
# @!attribute [r] originalIssue
|
40
|
+
# @return [Harkness::ComicSummary] a summary representation of the issue in which this story was
|
41
|
+
# originally published.
|
16
42
|
attribute :originalIssue, Harkness::ComicSummary
|
17
43
|
end
|
18
44
|
|
45
|
+
# Container class that holds pagination information and results.
|
19
46
|
class StoryDataContainer < Harkness::Base::DataContainer
|
47
|
+
# @!attribute [r] results
|
48
|
+
# @return [Array<Harkness::Story>] the list of stories returned by the call.
|
20
49
|
attribute :results, Harkness::Story, collection: true
|
21
50
|
end
|
22
51
|
|
52
|
+
# The top level wrapper of a response from the API.
|
23
53
|
class StoryDataWrapper < Harkness::Base::DataWrapper
|
54
|
+
# @!attribute [r] data
|
55
|
+
# @return [Harkness::StoryDataContainer] the results returned by the call.
|
24
56
|
attribute :data, Harkness::StoryDataContainer
|
25
57
|
end
|
26
58
|
end
|
@@ -1,13 +1,27 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Harkness
|
4
|
+
# The summary of a story.
|
4
5
|
class StorySummary < Harkness::Base::Summary
|
6
|
+
# @!attribute [r] type
|
7
|
+
# @return [String] the type of the story (interior or cover)
|
5
8
|
attribute :type, Shale::Type::String
|
6
9
|
end
|
7
10
|
|
11
|
+
# A list of stories.
|
8
12
|
class StoryList < Shale::Mapper
|
13
|
+
# @!attribute [r] available
|
14
|
+
# @return [Integer] the number of total available stories in this list.
|
15
|
+
# Will always be greater than or equal to the "returned" value.
|
9
16
|
attribute :available, Shale::Type::Integer
|
17
|
+
# @!attribute [r] returned
|
18
|
+
# @return [Integer] the number of stories 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 stories in this collection.
|
10
22
|
attribute :collectionURI, Shale::Type::String
|
23
|
+
# @!attribute [r] items
|
24
|
+
# @return [Array<Harkness::StorySummary>] the list of returned characters in this collection.
|
11
25
|
attribute :items, Harkness::StorySummary, collection: true
|
12
26
|
end
|
13
27
|
end
|
@@ -1,10 +1,16 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Harkness
|
4
|
-
# A text
|
4
|
+
# A text object.
|
5
5
|
class TextObject < Shale::Mapper
|
6
|
+
# @!attribute [r] type
|
7
|
+
# @return [String] the canonical type of the text object (e.g. solicit text, preview text, etc.).
|
6
8
|
attribute :type, Shale::Type::String
|
9
|
+
# @!attribute [r] language
|
10
|
+
# @return [String] the IETF language tag denoting the language the text object is written in.
|
7
11
|
attribute :language, Shale::Type::String
|
12
|
+
# @!attribute [r] text
|
13
|
+
# @return [String] the text.
|
8
14
|
attribute :text, Shale::Type::String
|
9
15
|
end
|
10
16
|
end
|
data/lib/harkness/models/url.rb
CHANGED
@@ -3,7 +3,11 @@
|
|
3
3
|
module Harkness
|
4
4
|
# A URL.
|
5
5
|
class URL < Shale::Mapper
|
6
|
+
# @!attribute [r] type
|
7
|
+
# @return [String] a text identifier for the URL.
|
6
8
|
attribute :type, Shale::Type::String
|
9
|
+
# @!attribute [r] url
|
10
|
+
# @return [String] a full URL (including scheme, domain, and path).
|
7
11
|
attribute :url, Shale::Type::String
|
8
12
|
end
|
9
13
|
end
|
data/lib/harkness/resource.rb
CHANGED
@@ -3,19 +3,33 @@
|
|
3
3
|
require "digest/md5"
|
4
4
|
|
5
5
|
module Harkness
|
6
|
+
# The base resource class.
|
6
7
|
class Resource
|
8
|
+
# A Harkness client.
|
9
|
+
# @return [Harkness::Client] the Harkness client.
|
7
10
|
attr_reader :client
|
8
11
|
|
12
|
+
# Initialize a new resource.
|
13
|
+
# @param client [Harkness::Client] the Harkness client.
|
9
14
|
def initialize(client)
|
10
15
|
@client = client
|
11
16
|
end
|
12
17
|
|
13
18
|
private
|
14
19
|
|
20
|
+
# Perform a GET request to a URL with params and headers.
|
21
|
+
# @param url [String] the URL to send the GET request to.
|
22
|
+
# @param params [Hash] URL query parameters to send with the request.
|
23
|
+
# @param headers [Hash] headers to send with the request
|
24
|
+
# @return [Faraday::Response, Harkness::Error] a Faraday response or Harkness:Error depending
|
25
|
+
# upon the status code.
|
15
26
|
def get_request(url, params: {}, headers: {})
|
16
27
|
handle_response client.connection.get(url, authentication_params.merge(params), headers)
|
17
28
|
end
|
18
29
|
|
30
|
+
# Generate the parameters necessary to authenticate with the Marvel API.
|
31
|
+
# See [`authorization`](https://developer.marvel.com/documentation/authorization) in the Marvel API documentation.
|
32
|
+
# @return [Hash] the calculated authentication parameters.
|
19
33
|
def authentication_params
|
20
34
|
timestamp = Time.now.to_i
|
21
35
|
{
|
@@ -25,6 +39,10 @@ module Harkness
|
|
25
39
|
}
|
26
40
|
end
|
27
41
|
|
42
|
+
# Handles a response from the API.
|
43
|
+
# @param response [Faraday::Response] the Faraday::Response from the API request.
|
44
|
+
# @return [Faraday::Response, Harkness::Error] a Faraday response or Harkness:Error depending
|
45
|
+
# upon the status code.
|
28
46
|
def handle_response(response)
|
29
47
|
error_klass = Harkness::Error::STATUS_MAPPINGS[response.status]
|
30
48
|
message = JSON.parse(response.body)["status"] || "API request failed with an unknown error."
|
data/lib/harkness/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: harkness
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- duffn
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-03-
|
11
|
+
date: 2023-03-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -247,7 +247,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
247
247
|
- !ruby/object:Gem::Version
|
248
248
|
version: '0'
|
249
249
|
requirements: []
|
250
|
-
rubygems_version: 3.4.
|
250
|
+
rubygems_version: 3.4.8
|
251
251
|
signing_key:
|
252
252
|
specification_version: 4
|
253
253
|
summary: A library for working (playing) with the Marvel API.
|