granatum-api 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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: a2bf5f73f81d941ccead29cceed5583e2ab6c3bc
4
+ data.tar.gz: ff1c304dbc219d35c73d160b631865cfea557ce2
5
+ SHA512:
6
+ metadata.gz: 31f33158b8afde4f68058d5ff6e779f235bf790b5199f1373b0fbac15b280334662f07027476d8872cc75f9daf67fe6929982058d16efa0098b41b5d9e2279b4
7
+ data.tar.gz: 10109ae9bbf7d6840ec0c9d6a57736462902726631a8cc236d1cc705a3810c3c865a9a03b38a78a2557db23d51ec4d81615ec4c5c119adc3b019f4fd3ed4383d
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.3
4
+ before_install: gem install bundler -v 1.10.6
@@ -0,0 +1,13 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
4
+
5
+ We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, or religion.
6
+
7
+ Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
8
+
9
+ Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
10
+
11
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
12
+
13
+ This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in granatum-api.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Sanderson Santana
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,53 @@
1
+ # Ruby Gem para a API do Granatum
2
+
3
+ Essa biblioteca é um conjunto de classes para acessar as informações do [Granatum](http://granatum.com.br) através da [API](http://www.granatum.com.br/financeiro/api/).
4
+
5
+ Todas as classes são herdadas do ActiveResouce::Base. Veja a documentação do [ActiveResouce](http://api.rubyonrails.org/classes/ActiveResource/Base.html) para mais informações.
6
+
7
+ ## Instalando
8
+
9
+ gem install granatum-api
10
+
11
+ ### Configurando seu token
12
+
13
+ ```ruby
14
+ require 'rubygems'
15
+ require 'granatum-api'
16
+
17
+ Granatum::Api::Base.access_token = ENV['granatum_token']
18
+ ```
19
+
20
+ ## Uso
21
+
22
+ ```ruby
23
+ # criar uma categoria
24
+ @category = Granatum::Api::Category.create({:description => 'Retirada de Lucro'})
25
+
26
+ # listar todos os lançamentos
27
+ @transactions = Granatum::Api::Transaction.find(:all, params: { conta_id: 46839})
28
+ @transactions.each do |transaction|
29
+ puts "ID: #{transaction.id}\n";
30
+ puts "Descricao: #{transaction.descricao}\n";
31
+ puts "Vencimento: #{transaction.data_vencimento}\n";
32
+ puts "Valor: #{transaction.valor}\n";
33
+ puts "=================================\n";
34
+ end
35
+ ```
36
+
37
+ Veja um exemplo no arquivo [example.rb](https://github.com/eita/granatum-api/blob/master/examples/example.rb)
38
+
39
+ ## Licença
40
+
41
+ Esse código é livre para ser usado dentro dos termos da licença [MIT license](http://www.opensource.org/licenses/mit-license.php).
42
+
43
+ ## Bugs, Issues, Agradecimentos, etc
44
+
45
+ Comentários são bem-vindos. Envie seu feedback através do [issue tracker do GitHub](http://github.com/eita/granatum-api/issues)
46
+
47
+ ## Referência
48
+
49
+ Agradecimento especial para o [CobreGratis-Ruby](https://github.com/CobreGratis/cobregratis-ruby) que serviu como referência para este código.
50
+
51
+ ## Autor
52
+
53
+ [**Sanderson Santana**](http://github.com/ssantana) trabalhando na [Eita](http://digaeita.com.br)
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "granatum/api"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,11 @@
1
+ $: << File.expand_path('../../lib', __FILE__)
2
+ require 'granatum/api'
3
+
4
+ @transactions = Granatum::Api::Transaction.find(:all, params: { conta_id: 46839})
5
+ @transactions.each do |transaction|
6
+ puts "ID: #{transaction.id}\n";
7
+ puts "Descricao: #{transaction.descricao}\n";
8
+ puts "Vencimento: #{transaction.data_vencimento}\n";
9
+ puts "Valor: #{transaction.valor}\n";
10
+ puts "=================================\n";
11
+ end
@@ -0,0 +1,36 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'granatum/api/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "granatum-api"
8
+ spec.version = Granatum::Api::VERSION
9
+ spec.authors = ["Sanderson Santana"]
10
+ spec.email = ["sanderson@digaeita.com.br"]
11
+
12
+ spec.summary = 'Cliente ruby para integração com a API do Granatum. ( http://granatum.com.br)'
13
+ spec.description = 'Cliente ruby para integração com a API do Granatum. Maiores informações http://www.granatum.com.br/financeiro/api/'
14
+ spec.homepage = "http://github.com/eita/grantum-api"
15
+ spec.license = "MIT"
16
+
17
+ # Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
18
+ # delete this section to allow pushing this gem to any host.
19
+ if spec.respond_to?(:metadata)
20
+ spec.metadata['allowed_push_host'] = "https://rubygems.org"
21
+ else
22
+ raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
23
+ end
24
+
25
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
26
+ spec.bindir = "exe"
27
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
28
+ spec.require_paths = ["lib"]
29
+
30
+ spec.add_runtime_dependency 'activeresource', "~> 4.0"
31
+ spec.add_runtime_dependency 'activesupport', "~> 4.0"
32
+ spec.add_development_dependency "bundler", "~> 1.10"
33
+ spec.add_development_dependency "rake", "~> 10.0"
34
+ spec.add_development_dependency "rspec"
35
+ spec.add_development_dependency "httplog"
36
+ end
data/init.rb ADDED
@@ -0,0 +1 @@
1
+ require 'granatum/api'
@@ -0,0 +1,20 @@
1
+ require 'active_resource'
2
+ require 'granatum/api/version'
3
+
4
+ module Granatum
5
+ module Api
6
+ require 'granatum/api/base'
7
+ require 'granatum/api/customer'
8
+ require 'granatum/api/category'
9
+ require 'granatum/api/supplier'
10
+ require 'granatum/api/bank'
11
+ require 'granatum/api/bank_account'
12
+ require 'granatum/api/cost_center'
13
+ require 'granatum/api/bank_account'
14
+ require 'granatum/api/city'
15
+ require 'granatum/api/state'
16
+ require 'granatum/api/type'
17
+ require 'granatum/api/transaction'
18
+ require 'granatum/formats/granatum_format'
19
+ end
20
+ end
@@ -0,0 +1,8 @@
1
+ module Granatum
2
+ module Api
3
+ class Bank < Granatum::Api::Base
4
+ self.element_name = 'banco'
5
+ self.collection_name = 'bancos'
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,10 @@
1
+ module Granatum
2
+ module Api
3
+ class BankAccount < Granatum::Api::Base
4
+ self.element_name = 'conta'
5
+ self.collection_name = 'contas'
6
+
7
+ belongs_to :bank, class_name: 'Granatum::Api::Bank', foreign_key: 'banco_id'
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,39 @@
1
+ module Granatum
2
+ module Api
3
+ class Base < ActiveResource::Base
4
+ self.site = 'https://api.granatum.com.br/v1'
5
+ self.include_root_in_json = false
6
+ self.headers['Content-Type'] = 'application/x-www-form-urlencoded'
7
+
8
+ cattr_accessor :_access_token
9
+
10
+ def self.access_token
11
+ self._access_token
12
+ end
13
+
14
+ def self.access_token=(token)
15
+ self._access_token = token
16
+ end
17
+
18
+ def self.format
19
+ ActiveResource::Formats::GranatumFormat
20
+ end
21
+
22
+ def self.include_format_in_path
23
+ false
24
+ end
25
+
26
+ def self.element_path(id, prefix_options={}, query_option={})
27
+ super(id, prefix_options, query_option.merge({access_token: access_token}))
28
+ end
29
+
30
+ def self.collection_path(prefix_options={}, query_option={})
31
+ super(prefix_options, query_option.merge({access_token: access_token}))
32
+ end
33
+
34
+ def to_granatum(options)
35
+ self.attributes.to_query
36
+ end
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,8 @@
1
+ module Granatum
2
+ module Api
3
+ class Category < Granatum::Api::Base
4
+ self.element_name = 'categoria'
5
+ self.collection_name = 'categorias'
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ module Granatum
2
+ module Api
3
+ class City < Granatum::Api::Base
4
+ self.element_name = 'cidade'
5
+ self.collection_name = 'cidades'
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ module Granatum
2
+ module Api
3
+ class CostCenter < Granatum::Api::Base
4
+ self.element_name = 'centros_custo_lucro'
5
+ self.collection_name = 'centros_custo_lucro'
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ module Granatum
2
+ module Api
3
+ class Customer < Granatum::Api::Base
4
+ self.element_name = 'cliente'
5
+ self.collection_name = 'clientes'
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,10 @@
1
+ module Granatum
2
+ module Api
3
+ class State < Granatum::Api::Base
4
+ self.element_name = 'estado'
5
+ self.collection_name = 'estados'
6
+
7
+ has_many :cities, class_name: 'Granatum::Api::City'
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,8 @@
1
+ module Granatum
2
+ module Api
3
+ class Supplier < Granatum::Api::Base
4
+ self.element_name = 'fornecedor'
5
+ self.collection_name = 'fornecedores'
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ module Granatum
2
+ module Api
3
+ class Transaction < Granatum::Api::Base
4
+ self.element_name = 'lancamento'
5
+ self.collection_name = 'lancamentos'
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ module Granatum
2
+ module Api
3
+ class Type < Granatum::Api::Base
4
+ self.element_name = 'forma_pagamento'
5
+ self.collection_name = 'formas_pagamento'
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,5 @@
1
+ module Granatum
2
+ module Api
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
@@ -0,0 +1,25 @@
1
+ require 'active_support/core_ext/hash/conversions'
2
+ require 'active_support/json'
3
+
4
+ module ActiveResource
5
+ module Formats
6
+ module GranatumFormat
7
+ extend self
8
+
9
+ def extension
10
+ "granatum"
11
+ end
12
+
13
+ def mime_type
14
+ "application/json"
15
+ end
16
+
17
+ def encode(hash, options = nil)
18
+ end
19
+
20
+ def decode(json)
21
+ Formats.remove_root(ActiveSupport::JSON.decode(json))
22
+ end
23
+ end
24
+ end
25
+ end
metadata ADDED
@@ -0,0 +1,157 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: granatum-api
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Sanderson Santana
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2015-10-12 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: activeresource
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '4.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '4.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: activesupport
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '4.0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '4.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.10'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.10'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '10.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '10.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: httplog
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ description: Cliente ruby para integração com a API do Granatum. Maiores informações
98
+ http://www.granatum.com.br/financeiro/api/
99
+ email:
100
+ - sanderson@digaeita.com.br
101
+ executables: []
102
+ extensions: []
103
+ extra_rdoc_files: []
104
+ files:
105
+ - ".gitignore"
106
+ - ".rspec"
107
+ - ".travis.yml"
108
+ - CODE_OF_CONDUCT.md
109
+ - Gemfile
110
+ - LICENSE.txt
111
+ - README.md
112
+ - Rakefile
113
+ - bin/console
114
+ - bin/setup
115
+ - examples/example.rb
116
+ - granatum-api.gemspec
117
+ - init.rb
118
+ - lib/granatum/api.rb
119
+ - lib/granatum/api/bank.rb
120
+ - lib/granatum/api/bank_account.rb
121
+ - lib/granatum/api/base.rb
122
+ - lib/granatum/api/category.rb
123
+ - lib/granatum/api/city.rb
124
+ - lib/granatum/api/cost_center.rb
125
+ - lib/granatum/api/customer.rb
126
+ - lib/granatum/api/state.rb
127
+ - lib/granatum/api/supplier.rb
128
+ - lib/granatum/api/transaction.rb
129
+ - lib/granatum/api/type.rb
130
+ - lib/granatum/api/version.rb
131
+ - lib/granatum/formats/granatum_format.rb
132
+ homepage: http://github.com/eita/grantum-api
133
+ licenses:
134
+ - MIT
135
+ metadata:
136
+ allowed_push_host: https://rubygems.org
137
+ post_install_message:
138
+ rdoc_options: []
139
+ require_paths:
140
+ - lib
141
+ required_ruby_version: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ required_rubygems_version: !ruby/object:Gem::Requirement
147
+ requirements:
148
+ - - ">="
149
+ - !ruby/object:Gem::Version
150
+ version: '0'
151
+ requirements: []
152
+ rubyforge_project:
153
+ rubygems_version: 2.4.5.1
154
+ signing_key:
155
+ specification_version: 4
156
+ summary: Cliente ruby para integração com a API do Granatum. ( http://granatum.com.br)
157
+ test_files: []