nri_drafts-service 0.0.0.pre.beta.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +7 -0
  2. data/nri_drafts.rb +3 -0
  3. data/nri_drafts/service.rb +71 -0
  4. metadata +45 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 78a2a5c113f94528c976c81991efdd5135a4809650aa0626599b83bbb53f487e
4
+ data.tar.gz: 73393dbad6fc386f2cafeb488067712001fbfd2210f8e5a71d527c5d36258359
5
+ SHA512:
6
+ metadata.gz: 96cd7cfd8f01d3b481c03b8e6597228d362cf99b1a91c313ebc896631283f3583663e7cc8871edb778bb2b9f0cf1668d55b8099bdfb450726df87c4a793ac544
7
+ data.tar.gz: 9b80b3b55f19d699cd3b45ed0c1a0ac91d149f1ca6cc141c6a15d6f6f995ab5ad8b7b428a961cc9e06bebc26a951da836309b0b534d749d562e8a251762a0af8
data/nri_drafts.rb ADDED
@@ -0,0 +1,3 @@
1
+ module NriDrafts
2
+ end
3
+ require_relative 'nri_drafts/service.rb'
@@ -0,0 +1,71 @@
1
+ require "json"
2
+ require "net/http"
3
+ require "uri"
4
+
5
+ module NriDrafts
6
+ class Service
7
+ def initialize(origin, timeout = nil)
8
+ @origin = URI(origin)
9
+ @http = Net::HTTP.new(@origin.host, @origin.port)
10
+
11
+ unless timeout.nil?
12
+ @http.open_timeout = timeout
13
+ @http.read_timeout = timeout
14
+ end
15
+ end
16
+
17
+ def get_v1_drafts_uri()
18
+ URI("#{@origin}/v1/drafts")
19
+ end
20
+
21
+ def get_v1_drafts(authorization:)
22
+ req = Net::HTTP::Get.new(get_v1_drafts_uri())
23
+ req["Authorization"] = authorization
24
+
25
+ @http.request(req)
26
+ end
27
+
28
+ def get_v1_drafts_by_ids_uri(ids)
29
+ ids = if ids.kind_of?(Array) then ids.join(',') else ids end
30
+
31
+ URI("#{@origin}/v1/drafts/#{ids}")
32
+ end
33
+
34
+ def get_v1_drafts_by_ids(ids, authorization:)
35
+ ids = if ids.kind_of?(Array) then ids.join(',') else ids end
36
+
37
+ req = Net::HTTP::Get.new(get_v1_drafts_by_ids_uri(ids))
38
+ req["Authorization"] = authorization
39
+
40
+ @http.request(req)
41
+ end
42
+
43
+ def post_v1_drafts_uri()
44
+ URI("#{@origin}/v1/drafts")
45
+ end
46
+
47
+ def post_v1_drafts(body:, authorization:)
48
+ req = Net::HTTP::Post.new(post_v1_drafts_uri())
49
+ req["Content-Type"] = "application/json"
50
+ req["Authorization"] = authorization
51
+
52
+ @http.request(req, body)
53
+ end
54
+
55
+ def put_v1_drafts_by_id_uri(id)
56
+ id = if id.kind_of?(Array) then id.join(',') else id end
57
+
58
+ URI("#{@origin}/v1/drafts/#{id}")
59
+ end
60
+
61
+ def put_v1_drafts_by_id(id, body:, authorization:)
62
+ id = if id.kind_of?(Array) then id.join(',') else id end
63
+
64
+ req = Net::HTTP::Put.new(put_v1_drafts_by_id_uri(id))
65
+ req["Content-Type"] = "application/json"
66
+ req["Authorization"] = authorization
67
+
68
+ @http.request(req, body)
69
+ end
70
+ end
71
+ end
metadata ADDED
@@ -0,0 +1,45 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: nri_drafts-service
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.0.pre.beta.1
5
+ platform: ruby
6
+ authors:
7
+ - NoRedInk
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2019-06-18 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Clue code for interactions with the drafts service.
14
+ email: engineering@noredink.com
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - nri_drafts.rb
20
+ - nri_drafts/service.rb
21
+ homepage: https://noredink.com
22
+ licenses:
23
+ - MIT
24
+ metadata: {}
25
+ post_install_message:
26
+ rdoc_options: []
27
+ require_paths:
28
+ - "."
29
+ required_ruby_version: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ required_rubygems_version: !ruby/object:Gem::Requirement
35
+ requirements:
36
+ - - ">"
37
+ - !ruby/object:Gem::Version
38
+ version: 1.3.1
39
+ requirements: []
40
+ rubyforge_project:
41
+ rubygems_version: 2.7.6
42
+ signing_key:
43
+ specification_version: 4
44
+ summary: Clue code for interactions with the drafts service.
45
+ test_files: []