diograph_store 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: ec884861b409a31d723f386c52f50291e7e8e5c9
4
+ data.tar.gz: f0ed1d0ffb46dc2176ff55195f8eb5bb0da56893
5
+ SHA512:
6
+ metadata.gz: cbc060aa07021d7c01b74d8681e8db2510be9bb1b0f9bfd6338fce7f3d6b7fafd8cde9f09bb1099f9cc64c9c5089d855ef7126a9b935cae9326a795a1260d7da
7
+ data.tar.gz: b27c54f46e2ae4a9d60d64f36ceb81abb6e50f415a347db910fb6386878c5fcbb1c68c8f1e6817132cb97a806578773538571141d4ec59538815b4798a2d495d
@@ -0,0 +1,20 @@
1
+ require 'httparty'
2
+ require 'diograph_store/diograph_api_request'
3
+
4
+ module DiographStore
5
+
6
+ class << self
7
+
8
+ def create_diory(diory_hash)
9
+ request = create_diory_request(diory_hash)
10
+ response = HTTParty.post(request[0], request[1])
11
+ end
12
+
13
+ def create_diory_request(diory_hash)
14
+ request = DiographApiRequest.new("create", diory_hash)
15
+ [request.endpoint, request.options]
16
+ end
17
+
18
+ end
19
+
20
+ end
@@ -0,0 +1,46 @@
1
+ module DiographStore
2
+
3
+ class DiographApiRequest
4
+
5
+ def initialize(type, args)
6
+ if ENV["DIOGRAPH_STORE_HOST"].nil? || ENV["DIOGRAPH_STORE_TOKEN"].nil?
7
+ raise "DIOGRAPH_STORE_HOST or DIOGRAPH_STORE_TOKEN environmental variables not defined"
8
+ end
9
+ @host = ENV["DIOGRAPH_STORE_HOST"]
10
+ @token = ENV["DIOGRAPH_STORE_TOKEN"]
11
+
12
+ @diory_hash = args
13
+ end
14
+
15
+ def endpoint
16
+ "#{@host}/v1/diories"
17
+ end
18
+
19
+ def options
20
+ {
21
+ headers: headers,
22
+ body: body(@diory_hash)
23
+ }
24
+ end
25
+
26
+ # private
27
+
28
+ def headers
29
+ {
30
+ "Content-Type" => "application/vnd.api+json",
31
+ "Authorization" => @token
32
+ }
33
+ end
34
+
35
+ def body(diory_hash)
36
+ {
37
+ "data" => {
38
+ "type" => "diories",
39
+ "attributes" => diory_hash
40
+ }
41
+ }.to_json
42
+ end
43
+
44
+ end
45
+
46
+ end
metadata ADDED
@@ -0,0 +1,58 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: diograph_store
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Jouni Alanen
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2018-02-27 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: httparty
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '='
18
+ - !ruby/object:Gem::Version
19
+ version: 0.16.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '='
25
+ - !ruby/object:Gem::Version
26
+ version: 0.16.0
27
+ description: SDK for using Diograph API
28
+ email: jouni@diory.me
29
+ executables: []
30
+ extensions: []
31
+ extra_rdoc_files: []
32
+ files:
33
+ - lib/diograph_store.rb
34
+ - lib/diograph_store/diograph_api_request.rb
35
+ homepage: http://dioryme.github.io
36
+ licenses: []
37
+ metadata: {}
38
+ post_install_message:
39
+ rdoc_options: []
40
+ require_paths:
41
+ - lib
42
+ required_ruby_version: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: '0'
47
+ required_rubygems_version: !ruby/object:Gem::Requirement
48
+ requirements:
49
+ - - ">="
50
+ - !ruby/object:Gem::Version
51
+ version: '0'
52
+ requirements: []
53
+ rubyforge_project:
54
+ rubygems_version: 2.6.13
55
+ signing_key:
56
+ specification_version: 4
57
+ summary: SDK for using Diograph API
58
+ test_files: []