dovico 1.0.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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 67d5d34d0fb717d92b72759aaa52d4f859e06c18
4
+ data.tar.gz: a0661c8ada849a06068b0c5c998881a1ed679b92
5
+ SHA512:
6
+ metadata.gz: c1b6046789cdfed1e55347c610254c5f4154ac414c3c56ead42e5135f1ca72849ffa02ac5353c77777332fdaf10866a165c44fcbd746a3b24ad31dd95add0c19
7
+ data.tar.gz: a03029e6d62076b85c2ac5f2a7995dca2e8f50f3fd529720b0664f0c9a466a02f1ef06774fd8fa1d43f5f2f5663d0784f70be03a37ea916244fa535d9a29eecb
@@ -0,0 +1 @@
1
+ .git/
@@ -0,0 +1,4 @@
1
+ dovico.yml
2
+ coverage/
3
+ *.gem
4
+ Gemfile.lock
@@ -0,0 +1,15 @@
1
+ stages:
2
+ - build
3
+ - test
4
+
5
+ build docker image:
6
+ stage: build
7
+ tags: [ docker ]
8
+ script:
9
+ - make docker-build-image TAG=${CI_BUILD_REF}
10
+
11
+ specs:
12
+ stage: test
13
+ tags: [ docker ]
14
+ script:
15
+ - make docker-test TAG=$CI_BUILD_REF
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --order=random
@@ -0,0 +1 @@
1
+ 2.4.0
@@ -0,0 +1,28 @@
1
+ FROM ruby:2.4
2
+
3
+ # System dependencies: Add here any librairies needed for certain gems
4
+ RUN apt-get update \
5
+ && apt-get install -y libpq-dev \
6
+ && apt-get clean \
7
+ && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
8
+
9
+ # Application working directory
10
+ WORKDIR /home/dovico
11
+
12
+ # WARNING The following line is important to keep bundle config
13
+ # inside the app directory
14
+ ENV BUNDLE_APP_CONFIG /home/dovico/.bundle/
15
+ # Copy dependency file
16
+ COPY ./dovico-client.gemspec /home/dovico/dovico-client.gemspec
17
+ COPY ./lib/dovico/version.rb /home/dovico/lib/dovico/version.rb
18
+ COPY ./Gemfile /home/dovico/Gemfile
19
+
20
+ # Bundle
21
+ RUN bundle install
22
+
23
+ # Copy code
24
+ COPY ./ /home/dovico
25
+
26
+ # What to launch on container startup
27
+ ENTRYPOINT ["make"]
28
+ CMD ["run"]
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
@@ -0,0 +1,66 @@
1
+ WEEK ?= $(shell date +%V)
2
+ YEAR ?= $(shell date +%Y)
3
+ DAY ?= $(shell date +%F)
4
+ TAG ?= $(shell git log -1 --abbrev=10 --format=%h)
5
+
6
+ # Update the specified dependencies
7
+ install:
8
+ @command -v ruby >/dev/null 2>&1 || { echo >&2 "I require ruby but it's not installed. Aborting."; exit 1; }
9
+ @command -v bundle >/dev/null 2>&1 || gem install bundler;
10
+ bundle check || bundle install
11
+
12
+ # Run all the tests
13
+ test: bundler
14
+ bundle exec rake spec
15
+
16
+ build:
17
+ bundle exec gem build dovico-client.gemspec
18
+
19
+ help:
20
+ bundle exec bin/dovico --help
21
+
22
+ tasks:
23
+ bundle exec bin/dovico --tasks
24
+
25
+ myself:
26
+ bundle exec bin/dovico --myself
27
+
28
+ # Fill actions
29
+ current_week:
30
+ bundle exec bin/dovico --fill --current-week
31
+
32
+ week:
33
+ bundle exec bin/dovico --fill --year=$(YEAR) --week=$(WEEK)
34
+
35
+ today:
36
+ bundle exec bin/dovico --fill --today
37
+
38
+ day:
39
+ bundle exec bin/dovico --fill --day=$(DAY)
40
+
41
+ # Submit actions
42
+ submit-current-week:
43
+ bundle exec bin/dovico --submit --current-week
44
+
45
+ submit-week:
46
+ bundle exec bin/dovico --submit --year=$(YEAR) --week=$(WEEK)
47
+
48
+ submit-day:
49
+ bundle exec bin/dovico --submit --day=$(DAY)
50
+
51
+ submit-today:
52
+ bundle exec bin/dovico --submit --today
53
+
54
+ # Private - ensure gems are up-to-date
55
+ bundler:
56
+ bundle check>/dev/null || bundle install
57
+
58
+ docker-build-image:
59
+ docker images | grep capitainetrain/dovico | grep $(TAG) || docker build --force-rm -t capitainetrain/dovico:$(TAG) -f Dockerfile .
60
+
61
+ # Run tests in Docker image
62
+ docker-test: docker-build-image
63
+ docker run --rm capitainetrain/dovico:$(TAG) test
64
+
65
+
66
+ .PHONY: install test help tasks myself current_week week today day submit-current-week submit-week submit-day submit-today bundler docker-build-image docker-test
@@ -0,0 +1,106 @@
1
+ [![build status](https://scm.capitainetrain.com/capitainetrain/dovico-client/badges/master/build.svg)](https://scm.capitainetrain.com/capitainetrain/dovico-client/commits/master)
2
+ [![coverage report](https://scm.capitainetrain.com/capitainetrain/dovico-client/badges/master/coverage.svg)](https://scm.capitainetrain.com/capitainetrain/dovico-client/commits/master)
3
+
4
+ Repository for Dovico API management.
5
+
6
+ # Installation
7
+ ## Dovico authentication
8
+ Dovico provide a way to generate a 3rd party token. This token provide a full access to your account:
9
+ - Do not expose your token.
10
+ - If you believe your token has been exposed publicly, regenerate a new one. The previous token will be invalidated.
11
+
12
+ To generate a token:
13
+ * Login to https://login.dovico.com/index.aspx
14
+ * In **Options** tab, in the **Apps** part, click on the `Reset` button and copy your token
15
+
16
+ ## Local configuration
17
+ * Create a new YAML file `~/.dovico/dovico.yml` with the following content:
18
+
19
+ ~~~ruby
20
+ # Personal token. Can be reset through Dovico setting page
21
+ user_token: "<token you have copied from dovico.net page>"
22
+ # Your company's token
23
+ client_token: "<token given by your company's dovico admin>"
24
+ ~~~
25
+
26
+ ## Install required libraries
27
+ * Install Ruby 2.4.0
28
+ * `make install`
29
+
30
+ ## Setup your default timesheet
31
+ * List the available tasks with `make tasks`
32
+
33
+ ~~~
34
+ $ make tasks
35
+ == List of available projects ==
36
+ Project | Task | Description
37
+ 1200 | 100 | Sauron Project: Forge the One Ring
38
+ 1200 | 110 | Sauron Project: Attack Gondor
39
+ 1400 | 100 | Gandalf Project: Meet Bilbo
40
+ 1400 | 120 | Gandalf Project: Convince Frodo
41
+ 1600 | 100 | Frodo Project: Go home
42
+ ~~~
43
+
44
+ * For each tasks you work on, note the Project, Task and hours spent. You should have a total of 7 hours of work each day.
45
+ * In your `~/.dovico/dovico.yml` file, *append* it with the following content
46
+
47
+ ~~~ruby
48
+ # Personal token. Can be reset through Dovico setting page
49
+ user_token: "...."
50
+ # Your company's token
51
+ client_token: "...."
52
+ assignments:
53
+ default_day:
54
+ - project_id: 1234
55
+ task_id: 100
56
+ hours: 3
57
+ - project_id: 9999
58
+ task_id: 120
59
+ hours: 2
60
+ - project_id: 4321
61
+ task_id: 424
62
+ hours: 2
63
+ # Quotes around day are mandatory
64
+ # On leave: use an empty array
65
+ '2016-01-17': []
66
+ # Specific day: redefine each tasks
67
+ '2017-12-19':
68
+ - project_id: 1234
69
+ task_id: 456
70
+ hours: 6
71
+ - project_id: 4321
72
+ task_id: 424
73
+ hours: 1
74
+ ~~~
75
+
76
+ # Usage
77
+ ## Display informations on your account
78
+ `make myself`
79
+
80
+ ## Display the list of the tasks
81
+ `make tasks`
82
+
83
+ ## Fill the timesheet
84
+ ### For the current week
85
+ `make current_week`
86
+
87
+ ### For today
88
+ `make today`
89
+
90
+ ### For a specific [commercial week](http://www.epochconverter.com/weeks/)
91
+ `make week WEEK=49`
92
+
93
+ Year can be set too:
94
+ `make week YEAR=2015 WEEK=40`
95
+
96
+ ### For a specific day
97
+ `make day DAY=2017-12-31`
98
+
99
+ # Restrictions and known issues
100
+ * The timesheet are currently created, but not submitted. You still need to login and submit your timesheet
101
+ * The client can't edit already created timesheets for now.
102
+
103
+ You are warmly welcome to contribute to the project!
104
+
105
+ # Dovico API Documentation
106
+ * http://apideveloper.dovico.com/
@@ -0,0 +1,11 @@
1
+ # Test tasks
2
+ begin
3
+ require "ci/reporter/rake/rspec"
4
+ require "rspec/core/rake_task"
5
+ RSpec::Core::RakeTask.new(:spec)
6
+ task :rspec => "ci:setup:rspec"
7
+
8
+ # Default
9
+ task :default => :spec
10
+ rescue LoadError
11
+ end
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "dovico"
4
+ require "pry"
5
+
6
+ Pry.start
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ require 'dovico'
3
+
4
+ Dovico::App.new.run
@@ -0,0 +1,135 @@
1
+ # Dovico API
2
+
3
+ ## `/Employees`
4
+ ### Query myself
5
+ Query : `GET /Employees/me`
6
+
7
+ Response :
8
+ ~~~json
9
+ {
10
+ "Employees": [
11
+ {
12
+ "ID": "860",
13
+ "FirstName": "Theophile",
14
+ "LastName": "Helleboid",
15
+ "GetItemURI": "https://api.dovico.com/Employees/860/?version=5"
16
+ }
17
+ ]
18
+ }
19
+ ~~~
20
+
21
+ ## `/TimeEntries`
22
+ ### Get Time Entries for one employee
23
+ Query `GET TimeEntries/Employee/860`
24
+
25
+ Response:
26
+ ~~~json
27
+ {
28
+ "TimeEntries": [
29
+ {
30
+ "ID": "T4d5ba65f-9ebc-4587-a72c-8243b2612a2b",
31
+ "Sheet": {"ID":"0", "Status":"N", "RejectedReason":""},
32
+ "Client": {"ID":"0", "Name":"[None]", "GetItemURI":"N/A"},
33
+ "Project": {"ID":"1269", "Name":"Non-Project Related", "GetItemURI":"https://api.dovico.com/Projects/1269/?version=5"},
34
+ "Task": {"ID":"482", "Name":"Other", "GetItemURI":"https://api.dovico.com/Tasks/482/?version=5"},
35
+ "Employee": {"ID":"860", "Name":"Helleboid, Theophile", "GetItemURI":"https://api.dovico.com/Employees/860/?version=5"},
36
+ "Date": "2017-01-02",
37
+ "StartTime": "0900",
38
+ "StopTime": "1600",
39
+ "TotalHours": "7",
40
+ "Description":"",
41
+ "Billable": "T",
42
+ "Charge": "0",
43
+ "ChargeCurrency": {"ID":"-1", "Symbol":"£", "GetItemURI":"N/A"},
44
+ "OTCharge": "1",
45
+ "Wage": "0",
46
+ "WageCurrency":{"ID":"-1", "Symbol":"£", "GetItemURI":"N/A"},
47
+ "OTWage": "1",
48
+ "Prorate": "0",
49
+ "Integrate": "",
50
+ "CustomFields":[]
51
+ }
52
+ ],
53
+ "PrevPageURI": "N/A",
54
+ "NextPageURI": "N/A"
55
+ }
56
+ ~~~
57
+
58
+ ### Create a new TimeEntry
59
+ Query `POST /TimeEntries/`
60
+ Body :
61
+ ~~~json
62
+ [
63
+ {
64
+ "ProjectID": "1297",
65
+ "TaskID": "4917",
66
+ "EmployeeID": "111",
67
+ "Date": "2011-06-01",
68
+ "TotalHours": "1"
69
+ }
70
+ ]
71
+ ~~~
72
+
73
+
74
+ ## `/Assignments`
75
+ ### Get a list of Assignments (ie, projects)
76
+ Query: `GET /Assignments`
77
+
78
+ Response
79
+ ~~~json
80
+ {
81
+ "Assignments": [
82
+ {
83
+ "AssignmentID": "P1238",
84
+ "ItemID": "1238",
85
+ "Name": "C004 - iOS Optimisation",
86
+ "StartDate": "2017-01-04",
87
+ "FinishDate": "2018-01-04",
88
+ "EstimatedHours":"N/A",
89
+ "TimeBillableByDefault":"N/A",
90
+ "ExpensesBillableByDefault":"T",
91
+ "Charge": "N/A",
92
+ "ChargeCurrency":{"ID":"N/A", "Symbol":"N/A", "GetItemURI":"N/A"},
93
+ "Wage": "N/A",
94
+ "WageCurrency": {"ID":"N/A", "Symbol":"N/A", "GetItemURI":"N/A"},
95
+ "Prorate": "N/A",
96
+ "ETC": "N/A",
97
+ "Hide": "N/A",
98
+ "GetAssignmentsURI":"https://api.dovico.com/Assignments/P1238/?version=5",
99
+ "GetItemURI":"https://api.dovico.com/Projects/1238/?version=5"
100
+ }
101
+ ]
102
+ }
103
+ ~~~
104
+
105
+ ### Get a list of task linked to a Project (ie Task)
106
+ Query: `GET /Assignements/P1238`
107
+
108
+ Response
109
+ ~~~json
110
+ {
111
+ "Assignments": [
112
+ {
113
+ "AssignmentID": "T32197",
114
+ "ItemID": "100",
115
+ "Name": "Core Development",
116
+ "StartDate": "N/A",
117
+ "FinishDate": "N/A",
118
+ "EstimatedHours":"N/A",
119
+ "TimeBillableByDefault":"N/A",
120
+ "ExpensesBillableByDefault":"N/A",
121
+ "Charge": "N/A",
122
+ "ChargeCurrency": {"ID":"N/A", "Symbol":"N/A", "GetItemURI":"N/A"},
123
+ "Wage": "N/A",
124
+ "WageCurrency": {"ID":"N/A", "Symbol":"N/A", "GetItemURI":"N/A"},
125
+ "Prorate": "N/A",
126
+ "ETC": "N/A",
127
+ "Hide": "N/A",
128
+ "GetAssignmentsURI":"https://api.dovico.com/Assignments/T32197/?version=5",
129
+ "GetItemURI": "https://api.dovico.com/Tasks/100/?version=5"}],
130
+ "PrevPageURI": "N/A",
131
+ "NextPageURI": "N/A"
132
+ }
133
+ ]
134
+ }
135
+ ~~~
@@ -0,0 +1,39 @@
1
+ $: << File.expand_path("../lib", __FILE__)
2
+ require 'dovico/version'
3
+
4
+ Gem::Specification.new do |s|
5
+ s.name = 'dovico'
6
+ s.licenses = ['MIT']
7
+ s.version = Dovico::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = ['Théophile Helleboid', 'Paul Bonaud']
10
+ s.email = ['theophile.helleboid@trainline.com']
11
+ s.homepage = 'https://rubygems.org/gems/dovico'
12
+ s.summary = %q(Simple client & tools for http://www.dovico.com/.)
13
+ s.description = %q(Simple client & tools for http://www.dovico.com/.)
14
+
15
+ s.files = `git ls-files`.split("\n")
16
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
17
+ s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
18
+ s.require_paths = ['lib']
19
+
20
+ s.add_dependency 'easy_app_helper'
21
+ s.add_dependency 'active_attr'
22
+ s.add_dependency 'typhoeus'
23
+
24
+ s.add_development_dependency 'pry'
25
+ s.add_development_dependency 'guard'
26
+ s.add_development_dependency 'guard-rspec'
27
+ s.add_development_dependency 'guard-rubocop'
28
+ s.add_development_dependency 'rubocop'
29
+ s.add_development_dependency 'ci_reporter'
30
+ s.add_development_dependency 'ci_reporter_rspec'
31
+ s.add_development_dependency 'rack-test'
32
+ s.add_development_dependency 'rake'
33
+ s.add_development_dependency 'rspec'
34
+ s.add_development_dependency 'rspec-its'
35
+ s.add_development_dependency 'simplecov'
36
+ s.add_development_dependency 'simplecov-rcov'
37
+ s.add_development_dependency 'timecop'
38
+ s.add_development_dependency 'webmock'
39
+ end