doccy-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.
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,12 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in doccy-api.gemspec
4
+ gemspec
5
+
6
+ group :development do
7
+ # Testing
8
+ gem "rspec"
9
+ gem "rr"
10
+ gem "shoulda", ">= 0"
11
+ gem 'factory_girl_rails'
12
+ end
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Michael Cindric
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,97 @@
1
+ # Doccy::Api
2
+ Official Ruby wrapper for the https://www.doccyapp.com api
3
+
4
+ ## Installation
5
+
6
+ Add this line to your application's Gemfile:
7
+
8
+ gem 'doccy-api'
9
+
10
+ And then execute:
11
+
12
+ $ bundle
13
+
14
+ Or install it yourself as:
15
+
16
+ $ gem install doccy-api
17
+
18
+ ## Usage
19
+
20
+ Create a doccy_api.rb file in your config/initializers folder and add the following
21
+
22
+ Doccy::Config.mode = :production" # OPTIONAL defaults to staging.
23
+ Doccy::Config.app_key = "YOUR-PARTNER-KEY" #OPTIONAL you only need this to create client accounts.
24
+
25
+
26
+ ## Sections
27
+
28
+
29
+ * [Accounts](#accounts)
30
+ * [Templates](#templates)
31
+ * [Documents](#documents)
32
+ * [Emails](#emails)
33
+ * [Login](#login)
34
+
35
+
36
+ ## <a name="accounts"> Accounts</a>
37
+
38
+ Doccy Partners are able to create client accounts through their applications. To become a partner contact us at support@doccyapp.com for more information.
39
+
40
+ Create an account and a user:
41
+
42
+ Doccy::Accounts.create(company_name, user_name, email, password, options = {})
43
+
44
+
45
+ ## <a name="templates"> Templates </a>
46
+
47
+ Returns all Templates for that users account
48
+
49
+ Doccy::Templates.all(auth_token)
50
+
51
+
52
+ Returns a specific Template
53
+
54
+ Doccy::Templates.get(auth_token, template_id)
55
+
56
+
57
+ Uploads a Teamplate to Doccy
58
+
59
+ Doccy::Templates.upload(auth_token, template_params)
60
+
61
+
62
+ ## <a name="documents"> Documents </a>
63
+
64
+ Creates a Document from Template
65
+
66
+ Doccy::Documents.create(auth_token, template_id, document_params)
67
+
68
+ Returns a specific Document
69
+
70
+ Doccy::Documents.get(auth_token, template_id, document_id)
71
+
72
+
73
+ Downloads a Document
74
+
75
+ Doccy::Documents.download(auth_token, template_id, document_id)
76
+
77
+
78
+ ## <a name="emails"> Emails </a>
79
+
80
+ Will send a document via Doccy
81
+
82
+ Doccy::Documents.create(auth_token, template_id, document_id, email_params)
83
+
84
+ ## <a name="login"> Login </a>
85
+
86
+ This will return the auth_token for that user.
87
+
88
+ Doccy::Session.create(email, password)
89
+
90
+
91
+ ## Contributing
92
+
93
+ 1. Fork it
94
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
95
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
96
+ 4. Push to the branch (`git push origin my-new-feature`)
97
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/doccy-api.gemspec ADDED
@@ -0,0 +1,28 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'doccy/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "doccy-api"
8
+ spec.version = Doccy::VERSION
9
+ spec.authors = ["Sentia Australia Pty Ltd"]
10
+ spec.email = ["support@doccyapp.com"]
11
+ spec.summary = "Ruby wrapper around Doccy API"
12
+ spec.description = "Ruby wrapper around Doccy API for creating, sending and sharing documents. This api can be used if your a Doccy partner or just want to use Doccy in your app."
13
+ spec.homepage = "https://www.doccyapp.com"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.3"
22
+ spec.add_development_dependency "rake"
23
+ spec.add_development_dependency "rspec", "~> 2.6"
24
+
25
+ spec.add_dependency "httparty"
26
+ spec.add_dependency "json"
27
+
28
+ end
@@ -0,0 +1,16 @@
1
+ module Doccy
2
+
3
+ class Accounts
4
+ include HTTParty
5
+
6
+ def self.create(company_name, user_name, email, password, options = {})
7
+ receive_newsletter = options.delete(:receive_newsletter) || true
8
+
9
+ options = { query: { account: {company_name: company_name, user_name: user_name, email: email, password: password}, auth_token: Doccy::Config.partner_key } }
10
+ response = HTTParty.post("#{Doccy::Config.url}/partners/accounts.json", options)
11
+ end
12
+
13
+
14
+ end
15
+
16
+ end
@@ -0,0 +1,34 @@
1
+ module Doccy
2
+ module Config
3
+
4
+ class << self
5
+ attr_accessor :endpoints
6
+ attr_accessor :prefix
7
+ attr_accessor :partner_key
8
+ attr_accessor :app_secret
9
+ attr_accessor :mode
10
+ end
11
+
12
+ self.endpoints = {
13
+ :development => "http://localhost:3000",
14
+ :staging => "http://staging.doccyapp.com",
15
+ :production => "https://www.doccyapp.com"
16
+ }
17
+
18
+ self.prefix = "/1"
19
+ self.partner_key = nil
20
+ self.app_secret = nil
21
+ self.mode = :staging
22
+
23
+ def self.url
24
+ if self.mode == :production
25
+ [self.endpoints[:production], "/api", self.prefix, ].join
26
+ elsif self.mode == :development
27
+ [self.endpoints[:development], "/api", self.prefix, ].join
28
+ else
29
+ [self.endpoints[:staging], "/api", self.prefix, ].join
30
+ end
31
+ end
32
+
33
+ end
34
+ end
@@ -0,0 +1,25 @@
1
+ module Doccy
2
+
3
+ class Documents
4
+
5
+ def self.create(auth_token, template_id, document_params)
6
+ options = { query: { auth_token: auth_token, document: document_params} }
7
+
8
+ response = HTTParty.post("#{Doccy::Config.url}/templates/#{template_id}/documents.json", options)
9
+ end
10
+
11
+ def self.get(auth_token, template_id, document_id)
12
+ options = { query: { auth_token: auth_token} }
13
+
14
+ response = HTTParty.get("#{Doccy::Config.url}/templates/#{template_id}/documents/#{document_id}.json", options)
15
+ end
16
+
17
+ def self.download(auth_token, template_id, document_id)
18
+ options = { query: { auth_token: auth_token} }
19
+
20
+ response = HTTParty.get("#{Doccy::Config.url}/templates/#{template_id}/documents/#{document_id}/download.json", options)
21
+ end
22
+
23
+ end
24
+
25
+ end
@@ -0,0 +1,13 @@
1
+ module Doccy
2
+
3
+ class Emails
4
+ include HTTParty
5
+
6
+ def self.create(auth_token, template_id, document_id, email_params)
7
+ options = { query: { email: email_params, auth_token: auth_token} }
8
+ response = HTTParty.post("#{Doccy::Api::Config.url}/templates/#{template_id}/documents/#{document_id}/emails.json", options)
9
+ end
10
+
11
+ end
12
+
13
+ end
@@ -0,0 +1,13 @@
1
+ module Doccy
2
+
3
+ class Session
4
+ include HTTParty
5
+
6
+ def self.create(email, password)
7
+ options = { query: { email: email, password: password } }
8
+ response = HTTParty.post("#{Doccy::Api::Config.url}/sessions.json", options)
9
+ end
10
+
11
+ end
12
+
13
+ end
@@ -0,0 +1,27 @@
1
+ module Doccy
2
+ class Templates
3
+
4
+ def self.all(auth_token)
5
+ options = { query: { auth_token: auth_token } }
6
+
7
+ response = HTTParty.get("#{Doccy::Config.url}/templates.json", options)
8
+ end
9
+
10
+
11
+ def self.get(auth_token, template_id)
12
+ options = { query: { auth_token: auth_token } }
13
+
14
+ response = HTTParty.get("#{Doccy::Config.url}/templates/#{template_id}.json", options)
15
+ end
16
+
17
+ def self.upload(auth_token, template_params)
18
+ options = { query: { auth_token: auth_token , template: template_params} }
19
+
20
+ response = HTTParty.post("#{Doccy::Config.url}/templates.json", options)
21
+
22
+ # puts response.body
23
+ end
24
+
25
+ end
26
+
27
+ end
@@ -0,0 +1,3 @@
1
+ module Doccy
2
+ VERSION = "0.0.1"
3
+ end
data/lib/doccy.rb ADDED
@@ -0,0 +1,18 @@
1
+ require 'logger'
2
+
3
+ module Doccy
4
+
5
+ autoload :Accounts, "doccy/accounts"
6
+ autoload :Templates, "doccy/templates"
7
+ autoload :Documents, "doccy/documents"
8
+ autoload :Emails, "doccy/emails"
9
+ autoload :Session, "doccy/session"
10
+ autoload :Config, "doccy/config"
11
+ autoload :VERSION, "doccy/version"
12
+
13
+
14
+ def self.logger
15
+ @logger ||= Logger.new(STDOUT).tap { |logger| logger.level = Logger::INFO }
16
+ end
17
+
18
+ end
data/spec/api_spec.rb ADDED
@@ -0,0 +1,5 @@
1
+ require 'spec_helper'
2
+ require 'doccy'
3
+
4
+ describe Doccy do
5
+ end
@@ -0,0 +1,40 @@
1
+ FactoryGirl.define do
2
+
3
+ factory :account do
4
+ sequence(:name) { |n| "Sentia_#{n}" }
5
+ expires_at 30.days.from_now
6
+ active true
7
+ plan_id ""
8
+ subscription_id ""
9
+ payment_token ""
10
+ api_key ""
11
+ secret ""
12
+
13
+ trait :dropbox_authenticated do
14
+ dropbox_oauth_token "abc123"
15
+ dropbox_oauth_secret "def456"
16
+ end
17
+
18
+ trait :subscribed do
19
+ plan
20
+ subscription_id "abc123"
21
+ end
22
+
23
+ trait :expired do
24
+ expires_at 31.days.ago
25
+ end
26
+
27
+ trait :inactive do
28
+ active false
29
+ end
30
+
31
+ trait :with_owner do
32
+ association :owner, factory: :user
33
+ end
34
+
35
+ factory :subscribed_account, traits: [:subscribed, :with_owner]
36
+ factory :expired_account, traits: [:expired, :subscribed]
37
+ factory :inactive_account, traits: [:inactive, :subscribed]
38
+ end
39
+
40
+ end
@@ -0,0 +1,14 @@
1
+ include ActionDispatch::TestProcess
2
+
3
+ FactoryGirl.define do
4
+
5
+ factory :document do
6
+ converted_document { fixture_file_upload("spec/templates/Word-Template.docx", "application/msword") }
7
+ content {{"company-name"=>"b", "company-address"=>"c", "name"=>"d", "title"=>"e", "date"=>"f"}}
8
+ template_id 1
9
+ account
10
+ name "Agreement for Client"
11
+ end
12
+
13
+
14
+ end
@@ -0,0 +1,10 @@
1
+ FactoryGirl.define do
2
+
3
+ factory :email do
4
+ sequence(:subject) { |n| "Sentia#{n}" }
5
+ message "A cool document"
6
+ recipients "michael.cindric@sentia.com.au"
7
+ pdf false
8
+ end
9
+
10
+ end
@@ -0,0 +1,8 @@
1
+ FactoryGirl.define do
2
+
3
+ factory :partner do
4
+ sequence(:name) { |n| "name_#{n}" }
5
+ sequence(:auth_token) { |n| "token#{n}" }
6
+ end
7
+
8
+ end
@@ -0,0 +1,24 @@
1
+ include ActionDispatch::TestProcess
2
+
3
+ FactoryGirl.define do
4
+
5
+ factory :docx_template, class: Template do
6
+ sequence(:name) { |n| "docx_template#{n}" }
7
+ document_template { fixture_file_upload("spec/templates/Word-Template.docx", "application/msword") }
8
+ account
9
+ end
10
+
11
+ factory :pages_template, class: Template do
12
+ sequence(:name) { |n| "pages_template#{n}" }
13
+ document_template { fixture_file_upload("spec/templates/Pages-Template.pages", "application/octet-stream") }
14
+ account
15
+ end
16
+
17
+ factory :blank_template, class: Template do
18
+ sequence(:name) { |n| "blank_template#{n}" }
19
+ document_template { fixture_file_upload("spec/templates/blank.pages", "application/octet-stream") }
20
+ account
21
+ end
22
+
23
+
24
+ end
@@ -0,0 +1,27 @@
1
+ FactoryGirl.define do
2
+
3
+ factory :user do
4
+ sequence(:email) { |n| "dev#{n}@google.com" }
5
+ password "password"
6
+ password_confirmation "password"
7
+ name "Tony Stark"
8
+ account
9
+ majstor false
10
+
11
+ trait(:inactive) do
12
+ association :account, factory: :account, active: false
13
+ end
14
+
15
+ trait(:admin) do
16
+ majstor true
17
+ end
18
+
19
+ trait(:subscribed) do
20
+ association :account, factory: :subscribed_account
21
+ end
22
+
23
+ factory :admin, traits: [:admin]
24
+ factory :subscribed_user, traits: [:subscribed]
25
+ end
26
+
27
+ end
@@ -0,0 +1,31 @@
1
+ require 'api'
2
+ require 'spec_helper'
3
+
4
+ describe Doccy::Accounts do
5
+
6
+ describe "with valid partner details" do
7
+
8
+ it "should create a client account with valid params" do
9
+
10
+
11
+ account = Doccy::Accounts.create "company_name", "user_name", "email", "password"
12
+ end
13
+
14
+ it "should not create an client account with invalid params" do
15
+
16
+ end
17
+
18
+ end
19
+
20
+ describe "with invalid partner details" do
21
+
22
+ it "should not create an client account" do
23
+ response = mock :code => 403, :body => { error: "invalid_partner_account",
24
+ error_description: "An unknown error has occurred."}
25
+
26
+ end
27
+
28
+ end
29
+
30
+ end
31
+
@@ -0,0 +1,5 @@
1
+ require 'doccy'
2
+
3
+ RSpec.configure do |config|
4
+ config.mock_with :rr
5
+ end
metadata ADDED
@@ -0,0 +1,165 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: doccy-api
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Sentia Australia Pty Ltd
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-09-06 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: bundler
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: '1.3'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: '1.3'
30
+ - !ruby/object:Gem::Dependency
31
+ name: rake
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: rspec
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ~>
52
+ - !ruby/object:Gem::Version
53
+ version: '2.6'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: '2.6'
62
+ - !ruby/object:Gem::Dependency
63
+ name: httparty
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ type: :runtime
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ - !ruby/object:Gem::Dependency
79
+ name: json
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ! '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ type: :runtime
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ description: Ruby wrapper around Doccy API for creating, sending and sharing documents.
95
+ This api can be used if your a Doccy partner or just want to use Doccy in your app.
96
+ email:
97
+ - support@doccyapp.com
98
+ executables: []
99
+ extensions: []
100
+ extra_rdoc_files: []
101
+ files:
102
+ - .gitignore
103
+ - Gemfile
104
+ - LICENSE.txt
105
+ - README.md
106
+ - Rakefile
107
+ - doccy-api.gemspec
108
+ - lib/doccy.rb
109
+ - lib/doccy/accounts.rb
110
+ - lib/doccy/config.rb
111
+ - lib/doccy/documents.rb
112
+ - lib/doccy/emails.rb
113
+ - lib/doccy/session.rb
114
+ - lib/doccy/templates.rb
115
+ - lib/doccy/version.rb
116
+ - spec/api_spec.rb
117
+ - spec/factories/account_factory.rb
118
+ - spec/factories/document_factory.rb
119
+ - spec/factories/email_factory.rb
120
+ - spec/factories/partner_factory.rb
121
+ - spec/factories/template_factory.rb
122
+ - spec/factories/user_factory.rb
123
+ - spec/lib/account_spec.rb
124
+ - spec/spec_helper.rb
125
+ homepage: https://www.doccyapp.com
126
+ licenses:
127
+ - MIT
128
+ post_install_message:
129
+ rdoc_options: []
130
+ require_paths:
131
+ - lib
132
+ required_ruby_version: !ruby/object:Gem::Requirement
133
+ none: false
134
+ requirements:
135
+ - - ! '>='
136
+ - !ruby/object:Gem::Version
137
+ version: '0'
138
+ segments:
139
+ - 0
140
+ hash: -80846182938457042
141
+ required_rubygems_version: !ruby/object:Gem::Requirement
142
+ none: false
143
+ requirements:
144
+ - - ! '>='
145
+ - !ruby/object:Gem::Version
146
+ version: '0'
147
+ segments:
148
+ - 0
149
+ hash: -80846182938457042
150
+ requirements: []
151
+ rubyforge_project:
152
+ rubygems_version: 1.8.25
153
+ signing_key:
154
+ specification_version: 3
155
+ summary: Ruby wrapper around Doccy API
156
+ test_files:
157
+ - spec/api_spec.rb
158
+ - spec/factories/account_factory.rb
159
+ - spec/factories/document_factory.rb
160
+ - spec/factories/email_factory.rb
161
+ - spec/factories/partner_factory.rb
162
+ - spec/factories/template_factory.rb
163
+ - spec/factories/user_factory.rb
164
+ - spec/lib/account_spec.rb
165
+ - spec/spec_helper.rb