youversion_bible 0.1.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 +7 -0
- data/README.md +212 -0
- data/lib/youversion_bible/client.rb +75 -0
- data/lib/youversion_bible/configuration.rb +13 -0
- data/lib/youversion_bible/errors.rb +21 -0
- data/lib/youversion_bible/railtie.rb +11 -0
- data/lib/youversion_bible/resources/bibles.rb +76 -0
- data/lib/youversion_bible/resources/highlights.rb +42 -0
- data/lib/youversion_bible/resources/languages.rb +26 -0
- data/lib/youversion_bible/resources/licenses.rb +16 -0
- data/lib/youversion_bible/resources/organizations.rb +41 -0
- data/lib/youversion_bible/resources/verse_of_the_day.rb +17 -0
- data/lib/youversion_bible/version.rb +4 -0
- data/lib/youversion_bible.rb +30 -0
- data/youversion_bible.gemspec +32 -0
- metadata +142 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 63a4815a0351cf4859541a8799132bd5868de1fa454eeaac6f2360b2f9cf2bfb
|
|
4
|
+
data.tar.gz: b16ce0c33cb9070c65b4f705e9974a3e54cbb801cf1b236da0e91eb349cc862f
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: e927115ba7982594c29a1d0b6fd01b7fb8a2cc5154ec977f8f4ff4a2705b4f9147270f0f415b06640df56f7a3ceeaaf1d008572a3e9abd5fa7ec16b393641063
|
|
7
|
+
data.tar.gz: 41d0a7f82cb0eb89219ab400ab0f370dae480e7d82092949d0332e988b93f3e7e05815b6b9ccbe23637fb65c6033ade60dfe970ad25897f0d4c811d1b9731499
|
data/README.md
ADDED
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
# Youversion Bible API - Ruby
|
|
2
|
+
|
|
3
|
+
A Ruby wrapper for the YouVersion Platform Bible API built using
|
|
4
|
+
**Excon**.
|
|
5
|
+
|
|
6
|
+
This gem provides a Ruby client for interacting with the following
|
|
7
|
+
YouVersion API resources:
|
|
8
|
+
|
|
9
|
+
- Bibles
|
|
10
|
+
- Highlights
|
|
11
|
+
- Languages
|
|
12
|
+
- Licenses
|
|
13
|
+
- Organizations
|
|
14
|
+
- Verse of the Day
|
|
15
|
+
|
|
16
|
+
------------------------------------------------------------------------
|
|
17
|
+
|
|
18
|
+
## Installation
|
|
19
|
+
|
|
20
|
+
Add this line to your application's Gemfile:
|
|
21
|
+
|
|
22
|
+
``` ruby
|
|
23
|
+
gem "youversion_bible"
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Then execute:
|
|
27
|
+
|
|
28
|
+
``` bash
|
|
29
|
+
bundle install
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
------------------------------------------------------------------------
|
|
33
|
+
|
|
34
|
+
## Configuration
|
|
35
|
+
|
|
36
|
+
You must provide your **YouVersion Platform App Key**.
|
|
37
|
+
|
|
38
|
+
``` ruby
|
|
39
|
+
YouversionBible.configure do |config|
|
|
40
|
+
config.app_key = ENV["YVP_APP_KEY"]
|
|
41
|
+
end
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### Optional Configuration
|
|
45
|
+
|
|
46
|
+
``` ruby
|
|
47
|
+
YouversionBible.configure do |config|
|
|
48
|
+
config.app_key = ENV["YVP_APP_KEY"]
|
|
49
|
+
config.base_url = "https://api-dev.youversion.com/v1"
|
|
50
|
+
end
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
----------------------------------------------------------------------------
|
|
54
|
+
Setting Default Description
|
|
55
|
+
-------------- --------------------------------- ---------------------------
|
|
56
|
+
app_key ENV\["YVP_APP_KEY"\] Your YouVersion App Key
|
|
57
|
+
|
|
58
|
+
base_url https://api.youversion.com/v1 API base URL (prod or dev)
|
|
59
|
+
----------------------------------------------------------------------------
|
|
60
|
+
|
|
61
|
+
------------------------------------------------------------------------
|
|
62
|
+
|
|
63
|
+
## Usage
|
|
64
|
+
|
|
65
|
+
Create a client instance:
|
|
66
|
+
|
|
67
|
+
``` ruby
|
|
68
|
+
client = YouversionBible.client
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
------------------------------------------------------------------------
|
|
72
|
+
|
|
73
|
+
### Bibles
|
|
74
|
+
|
|
75
|
+
``` ruby
|
|
76
|
+
client.bibles(language_ranges: ["en"])
|
|
77
|
+
client.bible(100)
|
|
78
|
+
client.bible_index(100)
|
|
79
|
+
|
|
80
|
+
client.passage(
|
|
81
|
+
bible_id: 100,
|
|
82
|
+
passage_id: "JHN.3.16"
|
|
83
|
+
)
|
|
84
|
+
|
|
85
|
+
client.books(100)
|
|
86
|
+
|
|
87
|
+
client.book(
|
|
88
|
+
bible_id: 100,
|
|
89
|
+
book_id: "GEN"
|
|
90
|
+
)
|
|
91
|
+
|
|
92
|
+
client.chapters(
|
|
93
|
+
bible_id: 100,
|
|
94
|
+
book_id: "GEN"
|
|
95
|
+
)
|
|
96
|
+
|
|
97
|
+
client.chapter(
|
|
98
|
+
bible_id: 100,
|
|
99
|
+
book_id: "GEN",
|
|
100
|
+
chapter_id: 1
|
|
101
|
+
)
|
|
102
|
+
|
|
103
|
+
client.verses(
|
|
104
|
+
bible_id: 100,
|
|
105
|
+
book_id: "GEN",
|
|
106
|
+
chapter_id: 1
|
|
107
|
+
)
|
|
108
|
+
|
|
109
|
+
client.verse(
|
|
110
|
+
bible_id: 100,
|
|
111
|
+
book_id: "GEN",
|
|
112
|
+
chapter_id: 1,
|
|
113
|
+
verse_id: 1
|
|
114
|
+
)
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
------------------------------------------------------------------------
|
|
118
|
+
|
|
119
|
+
### Languages
|
|
120
|
+
|
|
121
|
+
``` ruby
|
|
122
|
+
client.languages
|
|
123
|
+
client.language("en")
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
------------------------------------------------------------------------
|
|
127
|
+
|
|
128
|
+
### Organizations
|
|
129
|
+
|
|
130
|
+
``` ruby
|
|
131
|
+
client.organizations
|
|
132
|
+
client.organization("organization_id")
|
|
133
|
+
client.organization_bibles("organization_id")
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
------------------------------------------------------------------------
|
|
137
|
+
|
|
138
|
+
### Verse of the Day
|
|
139
|
+
|
|
140
|
+
``` ruby
|
|
141
|
+
client.verse_of_the_day_calendar
|
|
142
|
+
client.verse_of_the_day(32)
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
------------------------------------------------------------------------
|
|
146
|
+
|
|
147
|
+
### Highlights
|
|
148
|
+
|
|
149
|
+
#### (Under Construction) Documentation limited and doesn't work with normal API key
|
|
150
|
+
|
|
151
|
+
``` ruby
|
|
152
|
+
client.highlights(
|
|
153
|
+
bible_id: 100,
|
|
154
|
+
passage_id: "JHN.3.16"
|
|
155
|
+
)
|
|
156
|
+
|
|
157
|
+
client.upsert_highlight(
|
|
158
|
+
bible_id: 100,
|
|
159
|
+
passage_id: "JHN.3.16",
|
|
160
|
+
color: "44aa44"
|
|
161
|
+
)
|
|
162
|
+
|
|
163
|
+
client.clear_highlights(
|
|
164
|
+
bible_id: 100,
|
|
165
|
+
passage_id: "JHN.3.16"
|
|
166
|
+
)
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
------------------------------------------------------------------------
|
|
170
|
+
|
|
171
|
+
### Licenses
|
|
172
|
+
|
|
173
|
+
#### (Under Construction) Documentation limited and doesn't work with normal API key
|
|
174
|
+
|
|
175
|
+
``` ruby
|
|
176
|
+
client.licenses
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
------------------------------------------------------------------------
|
|
180
|
+
|
|
181
|
+
## Error Handling
|
|
182
|
+
|
|
183
|
+
All API errors raise a subclass of:
|
|
184
|
+
|
|
185
|
+
``` ruby
|
|
186
|
+
YouversionBible::ApiError
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
Examples:
|
|
190
|
+
|
|
191
|
+
``` ruby
|
|
192
|
+
YouversionBible::Unauthorized
|
|
193
|
+
YouversionBible::NotFound
|
|
194
|
+
YouversionBible::RateLimited
|
|
195
|
+
YouversionBible::ServerError
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
Handle them as needed:
|
|
199
|
+
|
|
200
|
+
``` ruby
|
|
201
|
+
begin
|
|
202
|
+
client.bible(999999)
|
|
203
|
+
rescue YouversionBible::NotFound => e
|
|
204
|
+
puts e.message
|
|
205
|
+
end
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
------------------------------------------------------------------------
|
|
209
|
+
|
|
210
|
+
## License
|
|
211
|
+
|
|
212
|
+
MIT
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
require "excon"
|
|
2
|
+
require "json"
|
|
3
|
+
|
|
4
|
+
require_relative "resources/bibles"
|
|
5
|
+
require_relative "resources/highlights"
|
|
6
|
+
require_relative "resources/languages"
|
|
7
|
+
require_relative "resources/licenses"
|
|
8
|
+
require_relative "resources/organizations"
|
|
9
|
+
require_relative "resources/verse_of_the_day"
|
|
10
|
+
|
|
11
|
+
module YouversionBible
|
|
12
|
+
class Client
|
|
13
|
+
def initialize(config = YouversionBible.configuration)
|
|
14
|
+
@config = config
|
|
15
|
+
validate!
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
# Mix in resource modules
|
|
19
|
+
include YouversionBible::Resources::Bibles
|
|
20
|
+
include YouversionBible::Resources::Highlights
|
|
21
|
+
include YouversionBible::Resources::Languages
|
|
22
|
+
include YouversionBible::Resources::Licenses
|
|
23
|
+
include YouversionBible::Resources::Organizations
|
|
24
|
+
include YouversionBible::Resources::VerseOfTheDay
|
|
25
|
+
|
|
26
|
+
private
|
|
27
|
+
|
|
28
|
+
def validate!
|
|
29
|
+
raise ConfigurationError, "YouVersion app_key is required (set config.app_key or ENV['YVP_APP_KEY'])." if @config.app_key.to_s.strip.empty?
|
|
30
|
+
raise ConfigurationError, "base_url is required" if @config.base_url.to_s.strip.empty?
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def request(path:, query: nil, body: nil, headers: {}, method: :get)
|
|
34
|
+
request_headers = default_headers.merge(headers)
|
|
35
|
+
payload = body.nil? ? nil : JSON.generate(body)
|
|
36
|
+
url = @config.base_url + path
|
|
37
|
+
params = query.present? ? query : {}
|
|
38
|
+
connection = Excon.new(url, headers: request_headers, query: params.to_query, body: payload)
|
|
39
|
+
response = connection.request(method: method)
|
|
40
|
+
handle_response(response)
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def default_headers
|
|
44
|
+
{
|
|
45
|
+
"X-YVP-App-Key" => @config.app_key,
|
|
46
|
+
"Accept" => "application/json",
|
|
47
|
+
"Content-Type" => "application/json"
|
|
48
|
+
}
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def handle_response(response)
|
|
52
|
+
status = response.status
|
|
53
|
+
raw = response.body.to_s
|
|
54
|
+
parsed = raw.empty? ? nil : (JSON.parse(raw) rescue raw)
|
|
55
|
+
|
|
56
|
+
case status
|
|
57
|
+
when 200..299
|
|
58
|
+
parsed
|
|
59
|
+
when 400
|
|
60
|
+
raise BadRequest.new("Bad Request", status: status, body: parsed)
|
|
61
|
+
when 401
|
|
62
|
+
raise Unauthorized.new("Unauthorized (check X-YVP-App-Key)", status: status, body: parsed)
|
|
63
|
+
when 404
|
|
64
|
+
raise NotFound.new("Not Found", status: status, body: parsed)
|
|
65
|
+
when 429
|
|
66
|
+
raise RateLimited.new("Rate Limited", status: status, body: parsed)
|
|
67
|
+
when 500..599
|
|
68
|
+
raise ServerError.new("Server Error", status: status, body: parsed)
|
|
69
|
+
else
|
|
70
|
+
raise ApiError.new("Unexpected response status #{status}", status: status, body: parsed)
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
module YouversionBible
|
|
2
|
+
class Error < StandardError; end
|
|
3
|
+
class ConfigurationError < Error; end
|
|
4
|
+
|
|
5
|
+
class ApiError < Error
|
|
6
|
+
attr_reader :status, :body
|
|
7
|
+
|
|
8
|
+
def initialize(message, status:, body:)
|
|
9
|
+
super(message)
|
|
10
|
+
@status = status
|
|
11
|
+
@body = body
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
class Unauthorized < ApiError; end
|
|
16
|
+
class NotFound < ApiError; end
|
|
17
|
+
class RateLimited < ApiError; end
|
|
18
|
+
class ServerError < ApiError; end
|
|
19
|
+
class BadRequest < ApiError; end
|
|
20
|
+
end
|
|
21
|
+
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
module YouversionBible
|
|
2
|
+
module Resources
|
|
3
|
+
module Bibles
|
|
4
|
+
# GET /bibles
|
|
5
|
+
def bibles(language_ranges: ["en"], all_available: true, page_size: 100, fields: nil, page_token: nil, license_id: nil)
|
|
6
|
+
query = {
|
|
7
|
+
language_ranges: Array(language_ranges), # encoded as language_ranges[]
|
|
8
|
+
all_available: all_available,
|
|
9
|
+
page_size: page_size,
|
|
10
|
+
fields: fields, # fields[]
|
|
11
|
+
page_token: page_token
|
|
12
|
+
}
|
|
13
|
+
query.merge!({license_id: license_id}) if license_id.present?
|
|
14
|
+
request(
|
|
15
|
+
path: "/bibles",
|
|
16
|
+
query: query
|
|
17
|
+
)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
# GET /bibles/{bible_id}
|
|
21
|
+
def bible(bible_id)
|
|
22
|
+
request(path: "/bibles/#{bible_id}")
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
# GET /bibles/{bible_id}/index
|
|
26
|
+
def bible_index(bible_id)
|
|
27
|
+
request(path: "/bibles/#{bible_id}/index")
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
# GET /bibles/{bible_id}/passages/{passage_id}
|
|
31
|
+
# passage_id examples: "JHN.3.16", "GEN.1", "MAT.1.1-5" (per docs usage)
|
|
32
|
+
def passage(bible_id:, passage_id:)
|
|
33
|
+
request(path: "/bibles/#{bible_id}/passages/#{escape_path(passage_id)}")
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
# GET /bibles/{bible_id}/books
|
|
37
|
+
def books(bible_id)
|
|
38
|
+
request(path: "/bibles/#{bible_id}/books")
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
# GET /bibles/{bible_id}/books/{book_id}
|
|
42
|
+
# book_id example: "JHN", "GEN" (USFM)
|
|
43
|
+
def book(bible_id:, book_id:)
|
|
44
|
+
request(path: "/bibles/#{bible_id}/books/#{escape_path(book_id)}")
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
# GET /bibles/{bible_id}/books/{book_id}/chapters
|
|
48
|
+
def chapters(bible_id:, book_id:)
|
|
49
|
+
request(path: "/bibles/#{bible_id}/books/#{escape_path(book_id)}/chapters")
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
# GET /bibles/{bible_id}/books/{book_id}/chapters/{chapter_id}
|
|
53
|
+
def chapter(bible_id:, book_id:, chapter_id:)
|
|
54
|
+
request(path: "/bibles/#{bible_id}/books/#{escape_path(book_id)}/chapters/#{chapter_id}")
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
# GET /bibles/{bible_id}/books/{book_id}/chapters/{chapter_id}/verses
|
|
58
|
+
def verses(bible_id:, book_id:, chapter_id:)
|
|
59
|
+
request(path: "/bibles/#{bible_id}/books/#{escape_path(book_id)}/chapters/#{chapter_id}/verses")
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
# GET /bibles/{bible_id}/books/{book_id}/chapters/{chapter_id}/verses/{verse_id}
|
|
63
|
+
def verse(bible_id:, book_id:, chapter_id:, verse_id:)
|
|
64
|
+
request(path: "/bibles/#{bible_id}/books/#{escape_path(book_id)}/chapters/#{chapter_id}/verses/#{verse_id}")
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
private
|
|
68
|
+
|
|
69
|
+
def escape_path(str)
|
|
70
|
+
# Basic safe escaping for path segments (spaces, etc.)
|
|
71
|
+
CGI.escape(str.to_s).gsub("+", "%20")
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
module YouversionBible
|
|
2
|
+
module Resources
|
|
3
|
+
module Highlights
|
|
4
|
+
# TODO not sure how these are supposed to work
|
|
5
|
+
# it looks like per user as we get an API key error but docs are not clear
|
|
6
|
+
|
|
7
|
+
# GET /highlights?bible_id=...&passage_id=...
|
|
8
|
+
def highlights(bible_id:, passage_id:)
|
|
9
|
+
request(
|
|
10
|
+
path: "/highlights",
|
|
11
|
+
query: { bible_id: bible_id, passage_id: passage_id }
|
|
12
|
+
)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
# POST /highlights { bible_id, passage_id, color }
|
|
16
|
+
# color must be 6-char hex like "44aa44"
|
|
17
|
+
def upsert_highlight(bible_id:, passage_id:, color:)
|
|
18
|
+
request(
|
|
19
|
+
method: :post,
|
|
20
|
+
path: "/highlights",
|
|
21
|
+
body: { bible_id: bible_id, passage_id: passage_id, color: color }
|
|
22
|
+
)
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
# DELETE /highlights/{passage_id_path}?bible_id=...
|
|
26
|
+
def clear_highlights(bible_id:, passage_id:)
|
|
27
|
+
request(
|
|
28
|
+
method: :delete,
|
|
29
|
+
path: "/highlights/#{escape_path(passage_id)}",
|
|
30
|
+
query: { bible_id: bible_id }
|
|
31
|
+
)
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
private
|
|
35
|
+
|
|
36
|
+
def escape_path(str)
|
|
37
|
+
CGI.escape(str.to_s).gsub("+", "%20")
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
module YouversionBible
|
|
2
|
+
module Resources
|
|
3
|
+
module Languages
|
|
4
|
+
# GET /languages
|
|
5
|
+
def languages(page_size: 100, fields: nil, page_token: nil, country: nil)
|
|
6
|
+
request(
|
|
7
|
+
path: "/languages",
|
|
8
|
+
query: { page_size: page_size, fields: fields, page_token: page_token, country: country }
|
|
9
|
+
)
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
# GET /languages/{language_id}
|
|
13
|
+
# language_id example: "en" or "sr-Latn"
|
|
14
|
+
def language(language_id)
|
|
15
|
+
request(path: "/languages/#{escape_path(language_id)}")
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
private
|
|
19
|
+
|
|
20
|
+
def escape_path(str)
|
|
21
|
+
CGI.escape(str.to_s).gsub("+", "%20")
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
module YouversionBible
|
|
2
|
+
module Resources
|
|
3
|
+
module Licenses
|
|
4
|
+
# GET /licenses
|
|
5
|
+
# Supports bible_id, developer_id, all_available per docs.
|
|
6
|
+
def licenses(bible_id: nil, all_available: true, developer_id: nil)
|
|
7
|
+
# TODO this one doesn't seem to work with the normal API key, figure out why
|
|
8
|
+
request(
|
|
9
|
+
path: "/licenses",
|
|
10
|
+
query: { all_available: all_available, bible_id: bible_id, developer_id: developer_id }
|
|
11
|
+
)
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
module YouversionBible
|
|
2
|
+
module Resources
|
|
3
|
+
module Organizations
|
|
4
|
+
# GET /organizations
|
|
5
|
+
def organizations(bible_id, accept_language: "en")
|
|
6
|
+
request(
|
|
7
|
+
path: "/organizations",
|
|
8
|
+
query: { bible_id: bible_id },
|
|
9
|
+
headers: { "Accept-Language" => accept_language }
|
|
10
|
+
)
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
# GET /organizations/{organization_id}
|
|
14
|
+
def organization(organization_id, accept_language: "en")
|
|
15
|
+
request(
|
|
16
|
+
path: "/organizations/#{escape_path(organization_id)}",
|
|
17
|
+
headers: { "Accept-Language" => accept_language }
|
|
18
|
+
)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
# GET /organizations/{organization_id}/bibles
|
|
22
|
+
def organization_bibles(organization_id, page_size: 100, fields: nil, page_token: nil)
|
|
23
|
+
query = {fields: fields, page_token: page_token }
|
|
24
|
+
if fields.present? && fields.count <= 3
|
|
25
|
+
query.merge!({page_size: page_size}) if page_size.present?
|
|
26
|
+
end
|
|
27
|
+
request(
|
|
28
|
+
path: "/organizations/#{escape_path(organization_id)}/bibles",
|
|
29
|
+
query: query
|
|
30
|
+
)
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
private
|
|
34
|
+
|
|
35
|
+
def escape_path(str)
|
|
36
|
+
CGI.escape(str.to_s).gsub("+", "%20")
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
module YouversionBible
|
|
2
|
+
module Resources
|
|
3
|
+
module VerseOfTheDay
|
|
4
|
+
# GET /verse_of_the_days
|
|
5
|
+
def verse_of_the_day_calendar
|
|
6
|
+
request(path: "/verse_of_the_days")
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
# GET /verse_of_the_days/{day}
|
|
10
|
+
# day: 1..365 (or 366)
|
|
11
|
+
def verse_of_the_day(day)
|
|
12
|
+
request(path: "/verse_of_the_days/#{day}")
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
require "youversion_bible/version"
|
|
2
|
+
require "youversion_bible/configuration"
|
|
3
|
+
require "youversion_bible/errors"
|
|
4
|
+
require "youversion_bible/client"
|
|
5
|
+
|
|
6
|
+
require "youversion_bible/resources/bibles"
|
|
7
|
+
require "youversion_bible/resources/highlights"
|
|
8
|
+
require "youversion_bible/resources/languages"
|
|
9
|
+
require "youversion_bible/resources/licenses"
|
|
10
|
+
require "youversion_bible/resources/organizations"
|
|
11
|
+
require "youversion_bible/resources/verse_of_the_day"
|
|
12
|
+
|
|
13
|
+
require "youversion_bible/railtie" if defined?(Rails)
|
|
14
|
+
|
|
15
|
+
module YouversionBible
|
|
16
|
+
class << self
|
|
17
|
+
def configure
|
|
18
|
+
yield(configuration)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def configuration
|
|
22
|
+
@configuration ||= Configuration.new
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def client
|
|
26
|
+
Client.new(configuration)
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
require_relative "lib/youversion_bible/version"
|
|
2
|
+
|
|
3
|
+
Gem::Specification.new do |spec|
|
|
4
|
+
spec.name = "youversion_bible"
|
|
5
|
+
spec.version = YouversionBible::VERSION
|
|
6
|
+
spec.authors = ["JD Warren"]
|
|
7
|
+
spec.email = ["johndavid400@gmail.com"]
|
|
8
|
+
|
|
9
|
+
spec.summary = "Ruby wrapper for the YouVersion Bible API"
|
|
10
|
+
spec.description = "A Ruby gem wrapper around the YouVersion Bible API. Includes: Bibles, Highlights, Languages, Licenses, Organizations, and Verse of the Day endpoints."
|
|
11
|
+
spec.homepage = "https://github.com/johndavid400/youversion_bible"
|
|
12
|
+
spec.license = "MIT"
|
|
13
|
+
|
|
14
|
+
spec.required_ruby_version = ">= 3.0"
|
|
15
|
+
|
|
16
|
+
# Files included in the gem
|
|
17
|
+
spec.files = Dir.chdir(__dir__) do
|
|
18
|
+
`git ls-files -z`.split("\x0")
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
spec.require_paths = ["lib"]
|
|
22
|
+
|
|
23
|
+
# Runtime dependencies
|
|
24
|
+
spec.add_dependency "excon", "~> 0.109"
|
|
25
|
+
spec.add_dependency "json", ">= 2.0"
|
|
26
|
+
|
|
27
|
+
# Dev dependencies
|
|
28
|
+
spec.add_development_dependency "rake", "~> 13.0"
|
|
29
|
+
spec.add_development_dependency "rspec", "~> 3.13"
|
|
30
|
+
spec.add_development_dependency "standard", "~> 1.35"
|
|
31
|
+
spec.add_development_dependency "pry", "~> 0.14"
|
|
32
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: youversion_bible
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- JD Warren
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2026-02-17 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: excon
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - "~>"
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '0.109'
|
|
20
|
+
type: :runtime
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - "~>"
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '0.109'
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: json
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - ">="
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '2.0'
|
|
34
|
+
type: :runtime
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - ">="
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '2.0'
|
|
41
|
+
- !ruby/object:Gem::Dependency
|
|
42
|
+
name: rake
|
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - "~>"
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: '13.0'
|
|
48
|
+
type: :development
|
|
49
|
+
prerelease: false
|
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - "~>"
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: '13.0'
|
|
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.13'
|
|
62
|
+
type: :development
|
|
63
|
+
prerelease: false
|
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
65
|
+
requirements:
|
|
66
|
+
- - "~>"
|
|
67
|
+
- !ruby/object:Gem::Version
|
|
68
|
+
version: '3.13'
|
|
69
|
+
- !ruby/object:Gem::Dependency
|
|
70
|
+
name: standard
|
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
|
72
|
+
requirements:
|
|
73
|
+
- - "~>"
|
|
74
|
+
- !ruby/object:Gem::Version
|
|
75
|
+
version: '1.35'
|
|
76
|
+
type: :development
|
|
77
|
+
prerelease: false
|
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
79
|
+
requirements:
|
|
80
|
+
- - "~>"
|
|
81
|
+
- !ruby/object:Gem::Version
|
|
82
|
+
version: '1.35'
|
|
83
|
+
- !ruby/object:Gem::Dependency
|
|
84
|
+
name: pry
|
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
|
86
|
+
requirements:
|
|
87
|
+
- - "~>"
|
|
88
|
+
- !ruby/object:Gem::Version
|
|
89
|
+
version: '0.14'
|
|
90
|
+
type: :development
|
|
91
|
+
prerelease: false
|
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
93
|
+
requirements:
|
|
94
|
+
- - "~>"
|
|
95
|
+
- !ruby/object:Gem::Version
|
|
96
|
+
version: '0.14'
|
|
97
|
+
description: 'A Ruby gem wrapper around the YouVersion Bible API. Includes: Bibles,
|
|
98
|
+
Highlights, Languages, Licenses, Organizations, and Verse of the Day endpoints.'
|
|
99
|
+
email:
|
|
100
|
+
- johndavid400@gmail.com
|
|
101
|
+
executables: []
|
|
102
|
+
extensions: []
|
|
103
|
+
extra_rdoc_files: []
|
|
104
|
+
files:
|
|
105
|
+
- README.md
|
|
106
|
+
- lib/youversion_bible.rb
|
|
107
|
+
- lib/youversion_bible/client.rb
|
|
108
|
+
- lib/youversion_bible/configuration.rb
|
|
109
|
+
- lib/youversion_bible/errors.rb
|
|
110
|
+
- lib/youversion_bible/railtie.rb
|
|
111
|
+
- lib/youversion_bible/resources/bibles.rb
|
|
112
|
+
- lib/youversion_bible/resources/highlights.rb
|
|
113
|
+
- lib/youversion_bible/resources/languages.rb
|
|
114
|
+
- lib/youversion_bible/resources/licenses.rb
|
|
115
|
+
- lib/youversion_bible/resources/organizations.rb
|
|
116
|
+
- lib/youversion_bible/resources/verse_of_the_day.rb
|
|
117
|
+
- lib/youversion_bible/version.rb
|
|
118
|
+
- youversion_bible.gemspec
|
|
119
|
+
homepage: https://github.com/johndavid400/youversion_bible
|
|
120
|
+
licenses:
|
|
121
|
+
- MIT
|
|
122
|
+
metadata: {}
|
|
123
|
+
post_install_message:
|
|
124
|
+
rdoc_options: []
|
|
125
|
+
require_paths:
|
|
126
|
+
- lib
|
|
127
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
128
|
+
requirements:
|
|
129
|
+
- - ">="
|
|
130
|
+
- !ruby/object:Gem::Version
|
|
131
|
+
version: '3.0'
|
|
132
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
133
|
+
requirements:
|
|
134
|
+
- - ">="
|
|
135
|
+
- !ruby/object:Gem::Version
|
|
136
|
+
version: '0'
|
|
137
|
+
requirements: []
|
|
138
|
+
rubygems_version: 3.4.19
|
|
139
|
+
signing_key:
|
|
140
|
+
specification_version: 4
|
|
141
|
+
summary: Ruby wrapper for the YouVersion Bible API
|
|
142
|
+
test_files: []
|