tiime 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: d412ea4fb36c24d9a1782f4a650c68d81df44e436e3f25c9fadc1e982f195dd1
4
+ data.tar.gz: a6d4add43d99ef98720319d81c8c8b550b875d43de7b5e502d6c6f6b4923edfb
5
+ SHA512:
6
+ metadata.gz: 682651226fcb0df354cadd2fd3459d2876f5b05d3a27fdfb137dce9bbefbed4990663c971956d03471d5f86a68a0df9ca91585fdf47eb376fdf5914dd15866f7
7
+ data.tar.gz: 51886d2da2b9a1c997b39e1a004d4e183ddfaf525a1dfc54eb1d1b9d0f62830af4a973b64464f50265784a96a9276173ffe96444ac03112d308daf15f95aca5c
data/.gitignore ADDED
@@ -0,0 +1,12 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
12
+ Gemfile.lock
data/.gitlab-ci.yml ADDED
@@ -0,0 +1,9 @@
1
+ image: ruby:2.5.5
2
+
3
+ before_script:
4
+ - gem install bundler -v 2.2.14
5
+ - bundle install
6
+
7
+ example_job:
8
+ script:
9
+ - bundle exec rake
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,9 @@
1
+ AllCops:
2
+ TargetRubyVersion: 2.5
3
+ NewCops: enable
4
+
5
+ Layout/LineLength:
6
+ Max: 120
7
+
8
+ Style/Documentation:
9
+ Enabled: false
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ ## [Unreleased]
2
+
3
+ ## [0.1.0] - 2022-04-05
4
+
5
+ - Initial release
@@ -0,0 +1,84 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
6
+
7
+ We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
8
+
9
+ ## Our Standards
10
+
11
+ Examples of behavior that contributes to a positive environment for our community include:
12
+
13
+ * Demonstrating empathy and kindness toward other people
14
+ * Being respectful of differing opinions, viewpoints, and experiences
15
+ * Giving and gracefully accepting constructive feedback
16
+ * Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
17
+ * Focusing on what is best not just for us as individuals, but for the overall community
18
+
19
+ Examples of unacceptable behavior include:
20
+
21
+ * The use of sexualized language or imagery, and sexual attention or
22
+ advances of any kind
23
+ * Trolling, insulting or derogatory comments, and personal or political attacks
24
+ * Public or private harassment
25
+ * Publishing others' private information, such as a physical or email
26
+ address, without their explicit permission
27
+ * Other conduct which could reasonably be considered inappropriate in a
28
+ professional setting
29
+
30
+ ## Enforcement Responsibilities
31
+
32
+ Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
33
+
34
+ Community leaders 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, and will communicate reasons for moderation decisions when appropriate.
35
+
36
+ ## Scope
37
+
38
+ This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
39
+
40
+ ## Enforcement
41
+
42
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at manu@localhost. All complaints will be reviewed and investigated promptly and fairly.
43
+
44
+ All community leaders are obligated to respect the privacy and security of the reporter of any incident.
45
+
46
+ ## Enforcement Guidelines
47
+
48
+ Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
49
+
50
+ ### 1. Correction
51
+
52
+ **Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
53
+
54
+ **Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
55
+
56
+ ### 2. Warning
57
+
58
+ **Community Impact**: A violation through a single incident or series of actions.
59
+
60
+ **Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
61
+
62
+ ### 3. Temporary Ban
63
+
64
+ **Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
65
+
66
+ **Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
67
+
68
+ ### 4. Permanent Ban
69
+
70
+ **Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
71
+
72
+ **Consequence**: A permanent ban from any sort of public interaction within the community.
73
+
74
+ ## Attribution
75
+
76
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
77
+ available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
78
+
79
+ Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
80
+
81
+ [homepage]: https://www.contributor-covenant.org
82
+
83
+ For answers to common questions about this code of conduct, see the FAQ at
84
+ https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
data/Gemfile ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ # Specify your gem's dependencies in tiime.gemspec
6
+ gemspec
7
+
8
+ gem 'rake', '~> 13.0'
9
+
10
+ gem 'rspec', '~> 3.0'
11
+
12
+ gem 'rubocop', '~> 1.7'
data/README.md ADDED
@@ -0,0 +1,48 @@
1
+ # Tiime
2
+
3
+ This gem `tiime` is a [Tiime](https://www.tiime.fr/) API client.
4
+
5
+ Please note that an unofficial API client as _Tiime_ do not provide official API support.
6
+
7
+ ## Usage
8
+
9
+ ```ruby
10
+ require 'tiime'
11
+
12
+ # Companies
13
+ pp Tiime::Company.all
14
+
15
+ my_company = Company.all.first
16
+
17
+ # Customers
18
+
19
+ pp Tiime::Customer.all(company_id: my_company.id)
20
+
21
+ # Bank accounts
22
+
23
+ pp Tiime::BankAccount.all(company_id: my_company.id)
24
+
25
+ # Bank transactions
26
+
27
+ pp Tiime::BankTransaction.all(company_id: my_company.id)
28
+
29
+ # Document
30
+
31
+ pp Tiime::Document.all(company_id: my_company.id)
32
+
33
+ ```
34
+
35
+ ## Development
36
+
37
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
38
+
39
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
40
+
41
+ ## Contributing
42
+
43
+ Bug reports and pull requests are welcome on GitHub at https://github.com/opus-codium/ruby-tiime.
44
+ This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/opus-codium/ruby-tiime/blob/main/CODE_OF_CONDUCT.md).
45
+
46
+ ## Code of Conduct
47
+
48
+ Everyone interacting in the Tiime project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/opus-codium/ruby-tiime/blob/main/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
4
+ require 'rspec/core/rake_task'
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ require 'rubocop/rake_task'
9
+
10
+ RuboCop::RakeTask.new
11
+
12
+ task default: %i[spec rubocop]
data/bin/console ADDED
@@ -0,0 +1,19 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require 'bundler/setup'
5
+ require 'tiime'
6
+
7
+ # You can add fixtures and/or initialization code here to make experimenting
8
+ # with your gem easier. You can also use a different console, if you like.
9
+
10
+ # (If you use this, don't forget to add pry to your Gemfile!)
11
+ # require "pry"
12
+ # Pry.start
13
+ raise 'TIIME_TOKEN environment variable is missing' if ENV['TIIME_TOKEN'].nil?
14
+
15
+ Flexirest::Base.cache_store = ActiveSupport::Cache::MemoryStore.new
16
+ Flexirest::Logger.logfile = Logger.new $stdout
17
+
18
+ require 'irb'
19
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
data/extra/Gemfile ADDED
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ gem 'capybara'
6
+ gem 'selenium-webdriver'
7
+ gem 'webdrivers'
data/extra/README.md ADDED
@@ -0,0 +1,19 @@
1
+ # Tiime extra
2
+
3
+ This directory contains a script that retrieves a token usable with Tiime API.
4
+
5
+ ## Usage
6
+
7
+ First run:
8
+
9
+ ```
10
+ bundle install
11
+ ```
12
+
13
+ ```
14
+ export TIIME_USER=john.doe@example.com
15
+ export TIIME_PASSWORD=Supersecret
16
+ # or
17
+ # export TIIME_PASSWORD=`pass show web/apps.tiime.fr/john.doe@example.com | head -n1`
18
+ bundle exec ./get_token
19
+ ```
data/extra/get_token ADDED
@@ -0,0 +1,32 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require 'capybara'
5
+ require 'capybara/dsl'
6
+ require 'webdrivers'
7
+
8
+ raise 'TIIME_USER environment variable is missing' if ENV['TIIME_USER'].nil?
9
+ raise 'TIIME_PASSWORD environment variable is missing' if ENV['TIIME_PASSWORD'].nil?
10
+
11
+ class Browser
12
+ include Capybara::DSL
13
+
14
+ def initialize
15
+ Capybara.configure do |config|
16
+ config.run_server = false
17
+ end
18
+
19
+ Capybara.current_driver = :selenium
20
+ end
21
+ end
22
+
23
+ b = Browser.new
24
+ b.visit 'https://apps.tiime.fr'
25
+ b.fill_in 'Adresse mail', with: ENV['TIIME_USER']
26
+ b.fill_in 'Mot de passe', with: ENV['TIIME_PASSWORD']
27
+ b.click_on 'Je me connecte'
28
+
29
+ b.find('.headline', text: 'Bonjour', wait: 30)
30
+ token = b.execute_script 'return localStorage.getItem("access_token");'
31
+
32
+ puts "TIIME_TOKEN=#{token}"
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'tiime/base_model'
4
+
5
+ module Tiime
6
+ class BankAccount < BaseModel
7
+ get :all, '/companies/:company_id/bank_accounts'
8
+ end
9
+ end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'tiime/bank_account'
4
+ require 'tiime/base_model'
5
+ require 'tiime/customer'
6
+ require 'tiime/document'
7
+ require 'tiime/invoice'
8
+
9
+ module Tiime
10
+ class BankTransaction < BaseModel
11
+ has_one :bank_account, BankAccount
12
+ has_many :receipts, Document
13
+ has_many :documents, Document
14
+
15
+ has_many :invoices, Invoice
16
+
17
+ has_many :clients, Customer
18
+
19
+ get :all, '/companies/:company_id/bank_transactions'
20
+ get :find, '/companies/:company_id/bank_transactions/:id'
21
+ end
22
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'flexirest'
4
+
5
+ module Tiime
6
+ class BaseModel < Flexirest::Base
7
+ base_url 'https://chronos-api.tiime-apps.com/v1'
8
+
9
+ before_request :set_bearer
10
+
11
+ def set_bearer(_name, request)
12
+ request.headers['Authorization'] = "Bearer #{ENV['TIIME_TOKEN']}"
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'tiime/base_model'
4
+ require 'tiime/bank_account'
5
+ require 'tiime/customer'
6
+
7
+ module Tiime
8
+ class Company < BaseModel
9
+ get :all, '/companies'
10
+ get :find, '/companies/:id'
11
+
12
+ def customers
13
+ Customer.all company_id: id
14
+ end
15
+
16
+ def bank_accounts
17
+ BankAccount.all company_id: id
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'tiime/base_model'
4
+
5
+ module Tiime
6
+ class Customer < BaseModel
7
+ get :all, '/companies/:company_id/clients'
8
+ get :find, '/companies/:company_id/clients/:id'
9
+ end
10
+ end
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'tiime/base_model'
4
+
5
+ module Tiime
6
+ class Document < BaseModel
7
+
8
+ class Category < BaseModel
9
+ get :all, '/companies/:company_id/document_categories'
10
+ get :find, '/companies/:company_id/document_categories/:id'
11
+ end
12
+
13
+ class Metadata < BaseModel; end
14
+
15
+ has_many :metadata, Metadata
16
+ has_one :category, Category
17
+
18
+ get :all, '/companies/:company_id/documents'
19
+ get :find, '/companies/:company_id/documents/:id'
20
+ get :download, '/companies/:company_id/documents/:id/file', plain: true
21
+ post :create, '/companies/:company_id/document_categories/:category_id/documents', request_body_type: :form_multipart
22
+ patch :update, '/companies/:company_id/documents/:id', request_body_type: :json
23
+ end
24
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'tiime/base_model'
4
+
5
+ module Tiime
6
+ class DocumentCategory < BaseModel
7
+ get :all, '/companies/:company_id/document_categories'
8
+ get :find, '/companies/:company_id/document_categories/:id'
9
+ end
10
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'tiime/base_model'
4
+
5
+ module Tiime
6
+ class Invoice < BaseModel
7
+ get :all, '/companies/:company_id/invoices'
8
+ get :find, '/companies/:company_id/invoices/:id'
9
+ end
10
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Tiime
4
+ VERSION = '0.1.0'
5
+ end
data/lib/tiime.rb ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'tiime/bank_account'
4
+ require 'tiime/bank_transaction'
5
+ require 'tiime/company'
6
+ require 'tiime/customer'
7
+
8
+ require 'tiime/version'
9
+
10
+ module Tiime
11
+ class Error < StandardError; end
12
+ end
data/tiime.gemspec ADDED
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'lib/tiime/version'
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = 'tiime'
7
+ spec.version = Tiime::VERSION
8
+ spec.authors = ['Manuel Tancoigne', 'Romuald Conty']
9
+ spec.email = ['manu@opus-labs.fr', 'romuald@opus-labs.fr']
10
+
11
+ spec.summary = 'Tiime client'
12
+ spec.description = 'REST client for the Tiime API'
13
+ spec.required_ruby_version = Gem::Requirement.new('>= 2.5.0')
14
+
15
+ # Specify which files should be added to the gem when it is released.
16
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
17
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
18
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features)/}) }
19
+ end
20
+ spec.bindir = 'exe'
21
+ spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
22
+ spec.require_paths = ['lib']
23
+
24
+ # Uncomment to register a new dependency of your gem
25
+ spec.add_dependency 'flexirest'
26
+
27
+ # For more information and examples about making a new gem, checkout our
28
+ # guide at: https://bundler.io/guides/creating_gem.html
29
+ spec.metadata['rubygems_mfa_required'] = 'true'
30
+ end
metadata ADDED
@@ -0,0 +1,84 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: tiime
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Manuel Tancoigne
8
+ - Romuald Conty
9
+ autorequire:
10
+ bindir: exe
11
+ cert_chain: []
12
+ date: 2022-04-12 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: flexirest
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - ">="
19
+ - !ruby/object:Gem::Version
20
+ version: '0'
21
+ type: :runtime
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ">="
26
+ - !ruby/object:Gem::Version
27
+ version: '0'
28
+ description: REST client for the Tiime API
29
+ email:
30
+ - manu@opus-labs.fr
31
+ - romuald@opus-labs.fr
32
+ executables: []
33
+ extensions: []
34
+ extra_rdoc_files: []
35
+ files:
36
+ - ".gitignore"
37
+ - ".gitlab-ci.yml"
38
+ - ".rspec"
39
+ - ".rubocop.yml"
40
+ - CHANGELOG.md
41
+ - CODE_OF_CONDUCT.md
42
+ - Gemfile
43
+ - README.md
44
+ - Rakefile
45
+ - bin/console
46
+ - bin/setup
47
+ - extra/Gemfile
48
+ - extra/README.md
49
+ - extra/get_token
50
+ - lib/tiime.rb
51
+ - lib/tiime/bank_account.rb
52
+ - lib/tiime/bank_transaction.rb
53
+ - lib/tiime/base_model.rb
54
+ - lib/tiime/company.rb
55
+ - lib/tiime/customer.rb
56
+ - lib/tiime/document.rb
57
+ - lib/tiime/document_category.rb
58
+ - lib/tiime/invoice.rb
59
+ - lib/tiime/version.rb
60
+ - tiime.gemspec
61
+ homepage:
62
+ licenses: []
63
+ metadata:
64
+ rubygems_mfa_required: 'true'
65
+ post_install_message:
66
+ rdoc_options: []
67
+ require_paths:
68
+ - lib
69
+ required_ruby_version: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - ">="
72
+ - !ruby/object:Gem::Version
73
+ version: 2.5.0
74
+ required_rubygems_version: !ruby/object:Gem::Requirement
75
+ requirements:
76
+ - - ">="
77
+ - !ruby/object:Gem::Version
78
+ version: '0'
79
+ requirements: []
80
+ rubygems_version: 3.1.2
81
+ signing_key:
82
+ specification_version: 4
83
+ summary: Tiime client
84
+ test_files: []