roqua-core-api 0.0.1
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/.document +3 -0
- data/.gitignore +5 -0
- data/.rspec +1 -0
- data/.yardopts +1 -0
- data/ChangeLog.md +5 -0
- data/Gemfile +7 -0
- data/LICENSE.txt +20 -0
- data/README.md +28 -0
- data/Rakefile +33 -0
- data/core_api.gemspec +28 -0
- data/lib/roqua-core-api.rb +1 -0
- data/lib/roqua/core_api.rb +5 -0
- data/lib/roqua/core_api/models.rb +2 -0
- data/lib/roqua/core_api/models/dossier.rb +15 -0
- data/lib/roqua/core_api/models/organization.rb +19 -0
- data/lib/roqua/core_api/sessions.rb +1 -0
- data/lib/roqua/core_api/sessions/app_session.rb +41 -0
- data/lib/roqua/core_api/version.rb +5 -0
- data/spec/core_api_spec.rb +7 -0
- data/spec/fixtures/Organizations/can_be_created.yml +50 -0
- data/spec/integration/organizations_spec.rb +11 -0
- data/spec/spec_helper.rb +11 -0
- metadata +168 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: abcd3e3f4bf1bd4306cb7e3e6132f408682099df
|
4
|
+
data.tar.gz: aade6681c604c4639e9fa81e13fb994e5aa757e2
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: d82f752d2478b8063fedac666b8655710d80abf2c8ce2169cc3b2762e2a780c2271dbe1d68770a59d8b8c8f90446ff3e93167eb2e15652f10dbe6b7767b73ad7
|
7
|
+
data.tar.gz: 97ce5478ac884beb0d334c2ce9be760a2cdb1a32a4bb04e5d975fc205160848559f6b742a97893c1a06e9e0349bfcdbeb321b0c7d6f5836215db6c6c9869580b
|
data/.document
ADDED
data/.gitignore
ADDED
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--colour --format documentation
|
data/.yardopts
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--markup markdown --title "core_api Documentation" --protected
|
data/ChangeLog.md
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2014 RoQua
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# core_api
|
2
|
+
|
3
|
+
* [Homepage](https://github.com/marten/core_api#readme)
|
4
|
+
* [Issues](https://github.com/marten/core_api/issues)
|
5
|
+
* [Documentation](http://rubydoc.info/gems/core_api/frames)
|
6
|
+
* [Email](mailto:marten at veldthuis.com)
|
7
|
+
|
8
|
+
## Description
|
9
|
+
|
10
|
+
TODO: Description
|
11
|
+
|
12
|
+
## Features
|
13
|
+
|
14
|
+
## Examples
|
15
|
+
|
16
|
+
require 'core_api'
|
17
|
+
|
18
|
+
## Requirements
|
19
|
+
|
20
|
+
## Install
|
21
|
+
|
22
|
+
$ gem install core_api
|
23
|
+
|
24
|
+
## Copyright
|
25
|
+
|
26
|
+
Copyright (c) 2014 Marten Veldthuis
|
27
|
+
|
28
|
+
See {file:LICENSE.txt} for details.
|
data/Rakefile
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
|
5
|
+
begin
|
6
|
+
require 'bundler'
|
7
|
+
rescue LoadError => e
|
8
|
+
warn e.message
|
9
|
+
warn "Run `gem install bundler` to install Bundler."
|
10
|
+
exit -1
|
11
|
+
end
|
12
|
+
|
13
|
+
begin
|
14
|
+
Bundler.setup(:development)
|
15
|
+
rescue Bundler::BundlerError => e
|
16
|
+
warn e.message
|
17
|
+
warn "Run `bundle install` to install missing gems."
|
18
|
+
exit e.status_code
|
19
|
+
end
|
20
|
+
|
21
|
+
require 'rake'
|
22
|
+
|
23
|
+
require 'rspec/core/rake_task'
|
24
|
+
RSpec::Core::RakeTask.new
|
25
|
+
|
26
|
+
task :test => :spec
|
27
|
+
task :default => :spec
|
28
|
+
|
29
|
+
require "bundler/gem_tasks"
|
30
|
+
|
31
|
+
require 'yard'
|
32
|
+
YARD::Rake::YardocTask.new
|
33
|
+
task :doc => :yard
|
data/core_api.gemspec
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
require File.expand_path('../lib/roqua/core_api/version', __FILE__)
|
4
|
+
|
5
|
+
Gem::Specification.new do |gem|
|
6
|
+
gem.name = "roqua-core-api"
|
7
|
+
gem.version = Roqua::CoreApi::VERSION
|
8
|
+
gem.summary = %q{API wrapper gem around Core's API}
|
9
|
+
gem.description = %q{Provides authenticated access to Core}
|
10
|
+
gem.license = "MIT"
|
11
|
+
gem.authors = ["Marten Veldthuis"]
|
12
|
+
gem.email = "marten@veldthuis.com"
|
13
|
+
gem.homepage = "https://github.com/roqua/core/blob/master/core_api/README.markdown"
|
14
|
+
|
15
|
+
gem.files = `git ls-files`.split($/)
|
16
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
17
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
18
|
+
gem.require_paths = ['lib']
|
19
|
+
|
20
|
+
gem.add_dependency 'httparty', '~> 0.12.0'
|
21
|
+
|
22
|
+
gem.add_development_dependency 'bundler', '~> 1.0'
|
23
|
+
gem.add_development_dependency 'rake', '~> 10.0'
|
24
|
+
gem.add_development_dependency 'rspec', '~> 3.0.0.beta1'
|
25
|
+
gem.add_development_dependency 'yard', '~> 0.8'
|
26
|
+
gem.add_development_dependency 'vcr', '~> 2.8.0'
|
27
|
+
gem.add_development_dependency 'webmock', '~> 1.17.1'
|
28
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'roqua/core_api'
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Roqua
|
2
|
+
module CoreApi
|
3
|
+
module Models
|
4
|
+
class Organization
|
5
|
+
def initialize(attributes)
|
6
|
+
@attributes = attributes
|
7
|
+
end
|
8
|
+
|
9
|
+
def key
|
10
|
+
@attributes.fetch("key")
|
11
|
+
end
|
12
|
+
|
13
|
+
def name
|
14
|
+
@attributes.fetch("name")
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'roqua/core_api/sessions/app_session'
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'httparty'
|
2
|
+
|
3
|
+
module Roqua
|
4
|
+
module CoreApi
|
5
|
+
module Sessions
|
6
|
+
# AppSession represents a session which is scoped to a specific app
|
7
|
+
# in the Core database. It deals with managing organizations and dossiers,
|
8
|
+
# but only on a anonymous base. It is not allowed to know who these dossiers
|
9
|
+
# represent.
|
10
|
+
class AppSession
|
11
|
+
include HTTParty
|
12
|
+
base_uri ENV["CORE_URL"]
|
13
|
+
|
14
|
+
attr_reader :key
|
15
|
+
|
16
|
+
def initialize(key)
|
17
|
+
@key = key
|
18
|
+
end
|
19
|
+
|
20
|
+
def create_organization(attributes)
|
21
|
+
response = post "/organizations", organization: attributes
|
22
|
+
raise response.inspect unless response.code == 201
|
23
|
+
Models::Organization.new(response)
|
24
|
+
end
|
25
|
+
|
26
|
+
def create_dossier(organization, attributes)
|
27
|
+
response = post "/organizations/#{organization.key}/dossiers", dossier: attributes
|
28
|
+
raise response.inspect unless response.code == 201
|
29
|
+
Models::Dossier.new(response)
|
30
|
+
end
|
31
|
+
|
32
|
+
private
|
33
|
+
|
34
|
+
def post(url, params = {})
|
35
|
+
# TODO: Handle authentication here
|
36
|
+
self.class.post("/apps/#{key}" + url + ".json", body: params)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: post
|
5
|
+
uri: http://core.dev/apps/development/organizations.json
|
6
|
+
body:
|
7
|
+
encoding: UTF-8
|
8
|
+
string: organization[key]=foobar&organization[name]=Foo%20Bar
|
9
|
+
headers: {}
|
10
|
+
response:
|
11
|
+
status:
|
12
|
+
code: 201
|
13
|
+
message: Created
|
14
|
+
headers:
|
15
|
+
Date:
|
16
|
+
- Tue, 28 Jan 2014 14:04:59 GMT
|
17
|
+
Server:
|
18
|
+
- Apache/2.2.24 (Unix) DAV/2 Phusion_Passenger/4.0.35 mod_ssl/2.2.24 OpenSSL/0.9.8y
|
19
|
+
X-Frame-Options:
|
20
|
+
- SAMEORIGIN
|
21
|
+
X-Xss-Protection:
|
22
|
+
- 1; mode=block
|
23
|
+
X-Content-Type-Options:
|
24
|
+
- nosniff
|
25
|
+
X-Ua-Compatible:
|
26
|
+
- chrome=1
|
27
|
+
Etag:
|
28
|
+
- "\"304439f64ca0ad5b9042da7c93ee58d2\""
|
29
|
+
Cache-Control:
|
30
|
+
- max-age=0, private, must-revalidate
|
31
|
+
X-Request-Id:
|
32
|
+
- a3f0d5c5-6118-4277-8bc3-f88344a5e8da
|
33
|
+
X-Runtime:
|
34
|
+
- '0.009867'
|
35
|
+
X-Powered-By:
|
36
|
+
- Phusion Passenger 4.0.35
|
37
|
+
Location:
|
38
|
+
- http://core.dev/apps/1/organizations/5
|
39
|
+
Status:
|
40
|
+
- 201 Created
|
41
|
+
Transfer-Encoding:
|
42
|
+
- chunked
|
43
|
+
Content-Type:
|
44
|
+
- application/json; charset=utf-8
|
45
|
+
body:
|
46
|
+
encoding: UTF-8
|
47
|
+
string: "{\"id\":5,\"key\":\"foobar\",\"name\":\"Foo Bar\",\"created_at\":\"2014-01-28T14:04:59.261Z\",\"updated_at\":\"2014-01-28T14:04:59.261Z\",\"app_id\":1}"
|
48
|
+
http_version:
|
49
|
+
recorded_at: Tue, 28 Jan 2014 14:04:59 GMT
|
50
|
+
recorded_with: VCR 2.8.0
|
@@ -0,0 +1,11 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'Organizations' do
|
4
|
+
let(:session) { Sessions::AppSession.new('development') }
|
5
|
+
|
6
|
+
it 'can be created', :vcr do
|
7
|
+
organization = session.create_organization(key: 'foobar', name: 'Foo Bar')
|
8
|
+
expect(organization.key).to eq("foobar")
|
9
|
+
expect(organization.name).to eq("Foo Bar")
|
10
|
+
end
|
11
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,168 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: roqua-core-api
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Marten Veldthuis
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-01-28 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.12.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.12.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.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: '10.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.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.0.0.beta1
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 3.0.0.beta1
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: yard
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0.8'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0.8'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: vcr
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 2.8.0
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 2.8.0
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: webmock
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: 1.17.1
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: 1.17.1
|
111
|
+
description: Provides authenticated access to Core
|
112
|
+
email: marten@veldthuis.com
|
113
|
+
executables: []
|
114
|
+
extensions: []
|
115
|
+
extra_rdoc_files: []
|
116
|
+
files:
|
117
|
+
- ".document"
|
118
|
+
- ".gitignore"
|
119
|
+
- ".rspec"
|
120
|
+
- ".yardopts"
|
121
|
+
- ChangeLog.md
|
122
|
+
- Gemfile
|
123
|
+
- LICENSE.txt
|
124
|
+
- README.md
|
125
|
+
- Rakefile
|
126
|
+
- core_api.gemspec
|
127
|
+
- lib/roqua-core-api.rb
|
128
|
+
- lib/roqua/core_api.rb
|
129
|
+
- lib/roqua/core_api/models.rb
|
130
|
+
- lib/roqua/core_api/models/dossier.rb
|
131
|
+
- lib/roqua/core_api/models/organization.rb
|
132
|
+
- lib/roqua/core_api/sessions.rb
|
133
|
+
- lib/roqua/core_api/sessions/app_session.rb
|
134
|
+
- lib/roqua/core_api/version.rb
|
135
|
+
- spec/core_api_spec.rb
|
136
|
+
- spec/fixtures/Organizations/can_be_created.yml
|
137
|
+
- spec/integration/organizations_spec.rb
|
138
|
+
- spec/spec_helper.rb
|
139
|
+
homepage: https://github.com/roqua/core/blob/master/core_api/README.markdown
|
140
|
+
licenses:
|
141
|
+
- MIT
|
142
|
+
metadata: {}
|
143
|
+
post_install_message:
|
144
|
+
rdoc_options: []
|
145
|
+
require_paths:
|
146
|
+
- lib
|
147
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
148
|
+
requirements:
|
149
|
+
- - ">="
|
150
|
+
- !ruby/object:Gem::Version
|
151
|
+
version: '0'
|
152
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
153
|
+
requirements:
|
154
|
+
- - ">="
|
155
|
+
- !ruby/object:Gem::Version
|
156
|
+
version: '0'
|
157
|
+
requirements: []
|
158
|
+
rubyforge_project:
|
159
|
+
rubygems_version: 2.2.1
|
160
|
+
signing_key:
|
161
|
+
specification_version: 4
|
162
|
+
summary: API wrapper gem around Core's API
|
163
|
+
test_files:
|
164
|
+
- spec/core_api_spec.rb
|
165
|
+
- spec/fixtures/Organizations/can_be_created.yml
|
166
|
+
- spec/integration/organizations_spec.rb
|
167
|
+
- spec/spec_helper.rb
|
168
|
+
has_rdoc:
|