paymo 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: ad2c072b47426d2a8da6501f38703c59fad6a4bb
4
+ data.tar.gz: 6b56a49fd6dd88349faea16821f813b1cdbf1cd6
5
+ SHA512:
6
+ metadata.gz: b2101e12090c4990898f7fbc17a6c634fd171e0dbe85a79bbbe3dc5c78294aaa1292271a0d55304622d70eb982357971e5492eb709deb730c468f641eb632887
7
+ data.tar.gz: c61e8cc503a6b887d2a482f6cbcadcc8ad1c334fcb0188a033a69fe0914c2020486a3200d617710593dcc964112d8d435330f9a27e6c52c7f2ffdf6786cb6042
@@ -0,0 +1,23 @@
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
18
+ .env
19
+ .DS_Store
20
+ fixtures/vcr_cassettes/*
21
+ .ruby-version
22
+ .ruby-gemset
23
+ bin/*
@@ -0,0 +1,6 @@
1
+ language: ruby
2
+ script: 'rake test'
3
+ notifications:
4
+ email:
5
+ recipients:
6
+ - james@jamesduncombe.com
data/Gemfile ADDED
@@ -0,0 +1,10 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
4
+
5
+ group :test do
6
+ gem 'rspec'
7
+ gem 'webmock'
8
+ gem 'vcr'
9
+ gem 'rake'
10
+ end
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 James Duncombe
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.
@@ -0,0 +1,31 @@
1
+ # Paymo
2
+
3
+ Gem for interfacing with Paymo's API.
4
+
5
+ ** Stay tuned... it's being built! **
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ gem 'paymo'
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install paymo
20
+
21
+ ## Usage
22
+
23
+ TODO: Write usage instructions here
24
+
25
+ ## Contributing
26
+
27
+ 1. Fork it
28
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
29
+ 3. Commit your changes (`git commit -am 'Added some feature'`)
30
+ 4. Push to the branch (`git push origin my-new-feature`)
31
+ 5. Create new Pull Request
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
3
+ require "rspec/core/rake_task"
4
+
5
+ RSpec::Core::RakeTask.new :test do |t|
6
+ t.pattern = 'spec/lib/paymo/**/*_spec.rb'
7
+ t.rspec_opts = ['--backtrace']
8
+ end
9
+
10
+ task :default => :test
@@ -0,0 +1,54 @@
1
+ require 'paymo/version'
2
+ require 'rest_client'
3
+ require 'json'
4
+
5
+ module Paymo
6
+
7
+ # Pull in our dependencies
8
+ ['/paymo/*.rb', '/paymo/models/*.rb', '/paymo/resources/*.rb'].each do |path|
9
+ Dir[File.dirname(__FILE__) + path].each { |f| require_relative f }
10
+ end
11
+
12
+ API_ENDPOINT = 'https://api.paymo.biz/service/'
13
+
14
+ class << self
15
+
16
+ attr_writer :auth_token, :debug
17
+
18
+ def api_key
19
+ ENV['PAYMO_API_KEY']
20
+ end
21
+
22
+ def auth_token
23
+ @auth_token ||= ''
24
+ end
25
+
26
+ def debug
27
+ @debug ||= false
28
+ end
29
+
30
+ end
31
+
32
+ class Base
33
+
34
+ def initialize(options = {})
35
+ @username = options[:username]
36
+ @password = options[:password]
37
+ @format = options[:format] || 'json'
38
+ self.auth
39
+ end
40
+
41
+ def auth
42
+ response = Paymo::API.post :auth, :login, {
43
+ format: @format,
44
+ username: @username,
45
+ password: @password,
46
+ api_key: Paymo.api_key
47
+ }
48
+ # add error checking
49
+ Paymo.auth_token = response['token']['_content']
50
+ end
51
+
52
+ end
53
+
54
+ end
@@ -0,0 +1,25 @@
1
+ module Paymo
2
+ class API
3
+
4
+ def self.methodize(resource, method)
5
+ method = method.to_s.gsub(/_([a-z]{1})/) { "#{$1.upcase}" }
6
+ "#{resource}.#{method}"
7
+ end
8
+
9
+ def self.get(resource, method, options = {})
10
+ method = methodize(resource, method)
11
+ options.merge!({ auth_token: Paymo.auth_token, api_key: Paymo.api_key, format: 'json' })
12
+ puts "curl #{API_ENDPOINT}paymo.#{method}?#{URI.encode_www_form(options)}" if Paymo.debug
13
+ json = RestClient.get "#{API_ENDPOINT}paymo.#{method}", { params: options }
14
+ JSON.parse(json)
15
+ end
16
+
17
+ def self.post(resource, method, options = {})
18
+ method = methodize(resource, method)
19
+ options.merge!({ auth_token: Paymo.auth_token, api_key: Paymo.api_key, format: 'json' })
20
+ puts "curl -X POST -d '#{URI.encode_www_form(options)}' #{API_ENDPOINT}paymo.#{method}" if Paymo.debug
21
+ json = RestClient.post "#{API_ENDPOINT}paymo.#{method}", options
22
+ JSON.parse(json)
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,28 @@
1
+ class Cache
2
+
3
+ def initialize(instance, method)
4
+ @data = {}
5
+ @instance = instance
6
+ @method = method
7
+ end
8
+
9
+ def get(key)
10
+ begin
11
+ @data.fetch(key)
12
+ rescue KeyError
13
+ set(key)
14
+ get(key)
15
+ end
16
+ end
17
+
18
+ def set(key)
19
+ @data.store key, value(key)
20
+ end
21
+
22
+ private
23
+
24
+ def value(key)
25
+ @instance.get_info(key).send @method
26
+ end
27
+
28
+ end
@@ -0,0 +1,67 @@
1
+ module Paymo
2
+ class Extras
3
+
4
+ def initialize(user_id)
5
+ @paymo_entries_instance = Paymo::Entries.new
6
+ @cache_instance = Cache.new(Paymo::Projects.new, :price_per_hour)
7
+ @end_time = Time.now
8
+ @user_id = user_id
9
+ end
10
+
11
+ def earnt_today?
12
+ run Date.today.to_time
13
+ end
14
+
15
+ def earnt_this_week?
16
+ start = Date.today + 1 - Date.today.wday
17
+ run start.to_time
18
+ end
19
+
20
+ def earnt_this_month?
21
+ run Time.new(Time.now.year, Time.now.month)
22
+ end
23
+
24
+ private
25
+
26
+ def run(time)
27
+ @start_time = time
28
+ get_entries
29
+ if @entries
30
+ build_projects_and_hours
31
+ build_per_hour_and_total
32
+ sum_total_overall_hours
33
+ else
34
+ 0.00
35
+ end
36
+ end
37
+
38
+ def get_entries
39
+ @entries = @paymo_entries_instance.find_by_user(@user_id, start: @start_time, end: @end_time)
40
+ end
41
+
42
+ def build_projects_and_hours
43
+ @project_ids_and_hours = @entries.map do |entry|
44
+ {
45
+ project_id: entry.project_id,
46
+ hours: span_of_hours_to_hours(entry)
47
+ }
48
+ end
49
+ end
50
+
51
+ def build_per_hour_and_total
52
+ @project_ids_and_hours.each do |entry|
53
+ entry[:per_hour] = @cache_instance.get(entry[:project_id])
54
+ entry[:total] = (entry[:per_hour] * entry[:hours])
55
+ end
56
+ end
57
+
58
+ def sum_total_overall_hours
59
+ @project_ids_and_hours.inject(0) { |sum, hash| sum + hash[:total] }
60
+ end
61
+
62
+ def span_of_hours_to_hours(entry)
63
+ ((entry.end.to_time - entry.start.to_time) / 60 / 60)
64
+ end
65
+
66
+ end
67
+ end
@@ -0,0 +1,23 @@
1
+ module Paymo
2
+ class Entry
3
+
4
+ attr_accessor :id, :added_manually, :billed, :start, :end, :description, :user_id, :user_name,
5
+ :task_id, :task_name, :project_id, :project_name
6
+
7
+ def initialize(result)
8
+ @id = result['id'].to_i
9
+ @added_manually = !!result['added_manually']
10
+ @billed = !!result['billed']
11
+ @start = DateTime.parse(result['start']['_content'])
12
+ @end = DateTime.parse(result['end']['_content'])
13
+ @description = result['description']['_content']
14
+ @user_id = result['user']['id'].to_i
15
+ @user_name = result['user']['name']
16
+ @task_id = result['task']['id'].to_i
17
+ @task_name = result['task']['name']
18
+ @project_id = result['project']['id'].to_i
19
+ @project_name = result['project']['name']
20
+ end
21
+
22
+ end
23
+ end
@@ -0,0 +1,19 @@
1
+ module Paymo
2
+ class Project
3
+
4
+ attr_accessor :id, :retired, :name, :description, :budget_hours,
5
+ :price_per_hour, :client_id, :client_name, :users
6
+
7
+ def initialize(result)
8
+ @id = result['id'].to_i
9
+ @retired = !!result['retired']
10
+ @name = result['name']['_content']
11
+ @description = result['description']['_content']
12
+ @budget_hours = result['budget_hours']['_content'].to_f
13
+ @price_per_hour = result['price_per_hour']['_content'].to_f
14
+ @client_id = result['client']['id'].to_i
15
+ @client_name = result['client']['name']
16
+ @users = result['users']
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,100 @@
1
+ module Paymo
2
+ class Entries
3
+
4
+ # Get detailed information about an entry.
5
+ def get_info(entry_id)
6
+ result = Paymo::API.get :entries, :get_info, entry_id: entry_id
7
+ if result['status'] == 'ok'
8
+ Paymo::Entry.new(result['entry'])
9
+ end
10
+ end
11
+
12
+ # Find entries for a specified user matching the optional time criteria.
13
+ # options - start_date, end_date
14
+ def find_by_user(user_id, options = {})
15
+ options.merge!({user_id: user_id })
16
+ if options[:start]
17
+ options[:start] = options[:start].strftime('%Y-%m-%d %H:%M:%S')
18
+ end
19
+ if options[:end]
20
+ options[:end] = options[:end].strftime('%Y-%m-%d %H:%M:%S')
21
+ end
22
+ result = Paymo::API.get :entries, :find_by_user, options
23
+ if result['status'] == 'ok'
24
+ if result['entries'].any?
25
+ result['entries']['entry'].map! do |entry|
26
+ Paymo::Entry.new(entry)
27
+ end
28
+ end
29
+ end
30
+ end
31
+
32
+ # Find entries for a specified task matching the optional time criteria.
33
+ # options - start_date, end_date
34
+ def find_by_task(task_id, options = {})
35
+ options.merge!({task_id: task_id })
36
+ Paymo::API.get :entries, :find_by_task, options
37
+ end
38
+
39
+ # Find entries for all tasks from the specified project matching the optional time criteria.
40
+ # options - start_date, end_date
41
+ def find_by_project(project_id, options = {})
42
+ options.merge!({project_id: project_id })
43
+ result = Paymo::API.get :entries, :find_by_project, options
44
+ if result['status'] == 'ok'
45
+ result['entries']['entry'].map! do |entry|
46
+ Paymo::Entry.new(entry)
47
+ end
48
+ end
49
+ end
50
+
51
+ # Returns the total amount of time tracked (in seconds) in all the entries for
52
+ # the given user matching the optional time criteria.
53
+ # options - start_date, end_date
54
+ def get_tracked_time_by_user(user_id, options = {})
55
+ options.merge!({user_id: user_id })
56
+ if options[:start]
57
+ options[:start] = options[:start].strftime('%Y-%m-%d %H:%M:%S')
58
+ end
59
+ if options[:end]
60
+ options[:end] = options[:end].strftime('%Y-%m-%d %H:%M:%S')
61
+ end
62
+ result = Paymo::API.get :entries, :get_tracked_time_by_user, options
63
+ { time: result['time']['_content'] }
64
+ end
65
+
66
+ # Returns the total amount of time tracked (in seconds) in all the entries for
67
+ # the given task matching the optional time criteria.
68
+ # options - start_date, end_date
69
+ def get_tracked_time_by_task(task_id, options = {})
70
+ options.merge!({task_id: task_id })
71
+ result = Paymo::API.get :entries, :get_tracked_time_by_task, options
72
+ { time: result['time']['_content'] }
73
+ end
74
+
75
+ # options - start_date, end_date
76
+ def get_tracked_time_by_project(project_id, options = {})
77
+ options.merge!({project_id: project_id })
78
+ result = Paymo::API.get :entries, :get_tracked_time_by_project, options
79
+ { time: result['time']['_content'] }
80
+ end
81
+
82
+
83
+ # options - hash of added_manually (boolean), billed (boolean), description (string)
84
+ def add(start_date, end_date, task_id, options = {})
85
+ end
86
+
87
+ #Â options - hash of billed (boolean) and description
88
+ def add_bulk(date, duration, task_id, options = {})
89
+ end
90
+
91
+ # options - task_id, added_manually = true, billed = false, description
92
+ def update(entry_id, start_date, end_date, options = {})
93
+ end
94
+
95
+
96
+ def delete(entry_id)
97
+ end
98
+
99
+ end
100
+ end
@@ -0,0 +1,25 @@
1
+ module Paymo
2
+ class Projects
3
+
4
+ def get_info(project_id)
5
+ result = Paymo::API.get :projects, :get_info, project_id: project_id
6
+ if result['status'] == 'ok'
7
+ Paymo::Project.new(result['project'])
8
+ end
9
+ end
10
+
11
+ def get_list(options = {})
12
+ result = Paymo::API.get :projects, :get_list, options
13
+ if result['status'] == 'ok'
14
+ projects = []
15
+ result['projects']['project'].each do |project|
16
+ # p project
17
+ projects << project
18
+ # projects << Paymo::Project.new(project)
19
+ end
20
+ projects.select { |a| a['retired'] == 0 }.uniq{ |c| c['client']['id'] }.each { |p| puts p['client']['name'] }
21
+ end
22
+ end
23
+
24
+ end
25
+ end
@@ -0,0 +1,18 @@
1
+ module Paymo
2
+ class Reports
3
+
4
+ def create(options = {})
5
+ if options[:start]
6
+ options[:start] = options[:start].strftime('%Y-%m-%d')
7
+ end
8
+ if options[:end]
9
+ options[:end] = options[:end].strftime('%Y-%m-%d')
10
+ end
11
+ result = Paymo::API.post :reports, :create, options
12
+ if result['status'] == 'ok'
13
+ result
14
+ end
15
+ end
16
+
17
+ end
18
+ end
@@ -0,0 +1,3 @@
1
+ module Paymo
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,21 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'paymo/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "paymo"
8
+ gem.version = Paymo::VERSION
9
+ gem.authors = ["James Duncombe"]
10
+ gem.email = ["james@jamesduncombe.com"]
11
+ gem.description = "Ruby wrapper for the Paymo API"
12
+ gem.summary = "Simple way to interact with the Paymo API"
13
+ gem.homepage = "https://github.com/jamesduncombe/paymo"
14
+ gem.license = 'MIT'
15
+
16
+ gem.files = `git ls-files`.split($\)
17
+ gem.test_files = gem.files.grep(%r{^(test|spec|features|fixtures)/})
18
+ gem.require_paths = ["lib"]
19
+
20
+ gem.add_runtime_dependency 'rest-client', '~> 1.6'
21
+ end
@@ -0,0 +1,18 @@
1
+ require 'spec_helper'
2
+
3
+ describe Paymo::API do
4
+
5
+ it 'returns a result when getting' do
6
+ VCR.use_cassette('auth') do
7
+ result = Paymo::API.post :auth, :login, username: 'james@jamesduncombe.com', password: ENV['PAYMO_PASS']
8
+ result['status'].should eq 'ok'
9
+ end
10
+ end
11
+
12
+ describe '#self.methodize' do
13
+ it 'returns a camerlized string' do
14
+ Paymo::API.methodize(:entries, :get_project).should eq 'entries.getProject'
15
+ end
16
+ end
17
+
18
+ end
@@ -0,0 +1,35 @@
1
+ require 'spec_helper'
2
+
3
+ describe Paymo::Extras do
4
+
5
+ before(:all) do
6
+ VCR.use_cassette('auth') do
7
+ Paymo::Base.new(username: 'james@jamesduncombe.com', password: ENV['PAYMO_PASS'])
8
+ end
9
+ end
10
+
11
+ describe '#earnt_today?' do
12
+ it 'returns how much a user has earnt today' do
13
+ VCR.use_cassette('extras.earnt_today', record: :new_episodes) do
14
+ Paymo::Extras.new(9308).earnt_today?.should be_an_instance_of Float
15
+ end
16
+ end
17
+ end
18
+
19
+ describe '#earnt_this_month?' do
20
+ it 'returns how much a user has earnt this month' do
21
+ VCR.use_cassette('extras.earnt_this_month', record: :new_episodes) do
22
+ Paymo::Extras.new(9308).earnt_this_month?.should be_an_instance_of Float
23
+ end
24
+ end
25
+ end
26
+
27
+ describe '#earnt_this_week?' do
28
+ it 'returns how much a user has earnt this week' do
29
+ VCR.use_cassette('extras.earnt_this_week', record: :new_episodes) do
30
+ Paymo::Extras.new(9308).earnt_this_week?.should be_an_instance_of Float
31
+ end
32
+ end
33
+ end
34
+
35
+ end
@@ -0,0 +1,92 @@
1
+ require 'spec_helper'
2
+
3
+ describe Paymo::Entries do
4
+
5
+ before(:all) do
6
+ VCR.use_cassette('auth') do
7
+ Paymo::Base.new(username: 'james@jamesduncombe.com', password: ENV['PAYMO_PASS'])
8
+ end
9
+ @pe = Paymo::Entries.new
10
+ end
11
+
12
+ describe '#get_info' do
13
+ it 'gets user info' do
14
+ VCR.use_cassette('entries.get_info', record: :new_episodes) do
15
+ result = @pe.get_info(10706552)
16
+ result.project_name.should eq 'IndieArtery'
17
+ end
18
+ end
19
+ end
20
+
21
+ describe '#find_by_user' do
22
+ it 'finds a user' do
23
+ VCR.use_cassette('entries.find_by_user', record: :new_episodes) do
24
+ @pe.find_by_user(9308).first.should be_an_instance_of Paymo::Entry
25
+ end
26
+ end
27
+ context 'with a start and end date supplied' do
28
+ it 'returns just projects worked on in that time frame' do
29
+ start_time = Time.new(2013, 5, 7)
30
+ end_time = Time.new(2013, 5, 7, 23, 59)
31
+ VCR.use_cassette('entries.get_info.with_start_end', record: :new_episodes) do
32
+ entries = @pe.find_by_user(9308, start: start_time, end: end_time)
33
+ entries.first.project_name.should eq 'Work'
34
+ end
35
+ end
36
+ end
37
+ end
38
+
39
+ describe '#find_by_task' do
40
+ it 'finds a task' do
41
+ VCR.use_cassette('entries.find_by_task', record: :new_episodes) do
42
+ @pe.find_by_task(1604790)['status'].should eql 'ok'
43
+ end
44
+ end
45
+ end
46
+
47
+ describe '#find_by_project' do
48
+ it 'finds a project' do
49
+ VCR.use_cassette('entries.find_by_project', record: :new_episodes) do
50
+ result = @pe.find_by_project(337047)
51
+ result.first.description.should eq 'Replying to email re members @ 92.'
52
+ end
53
+ end
54
+ end
55
+
56
+ describe '#get_tracked_time_by_user' do
57
+ context 'with no options supplied' do
58
+ it 'finds all tracked time by user' do
59
+ VCR.use_cassette('entries.get_tracked_time_by_user', record: :new_episodes) do
60
+ @pe.get_tracked_time_by_user(9308)[:time].should be_a Fixnum
61
+ end
62
+ end
63
+ end
64
+
65
+ context 'with a start and end date supplied' do
66
+ it 'returns the correct' do
67
+ start_time = Time.new(2013, 5, 8)
68
+ end_time = Time.new(2013, 5, 8, 23, 59)
69
+ VCR.use_cassette('entries.get_tracked_time_by_user.with_start_end', record: :new_episodes) do
70
+ @pe.get_tracked_time_by_user(9308, start: start_time, end: end_time )[:time].should be_a Fixnum
71
+ end
72
+ end
73
+ end
74
+ end
75
+
76
+ describe '#get_tracked_time_by_task' do
77
+ it 'finds all tracked time by task' do
78
+ VCR.use_cassette('entries.get_tracked_time_by_task', record: :new_episodes) do
79
+ @pe.get_tracked_time_by_task(1604790)[:time].should be_a Fixnum
80
+ end
81
+ end
82
+ end
83
+
84
+ describe '#get_tracked_time_by_project' do
85
+ it 'finds all tracked time by project' do
86
+ VCR.use_cassette('entries.get_tracked_time_by_project', record: :new_episodes) do
87
+ @pe.get_tracked_time_by_project(337047)[:time].should be_a Fixnum
88
+ end
89
+ end
90
+ end
91
+
92
+ end
@@ -0,0 +1,30 @@
1
+ require 'spec_helper'
2
+
3
+ describe Paymo::Projects do
4
+
5
+ before(:all) do
6
+ VCR.use_cassette('auth') do
7
+ Paymo::Base.new(username: 'james@jamesduncombe.com', password: ENV['PAYMO_PASS'])
8
+ end
9
+ @projects = Paymo::Projects.new
10
+ end
11
+
12
+ describe '#get_info' do
13
+ it 'returns information about the project' do
14
+ VCR.use_cassette('projects.get_info', record: :new_episodes) do
15
+ result = @projects.get_info(802485)
16
+ result.name.should be_a String
17
+ end
18
+ end
19
+ end
20
+
21
+ describe '#get_list' do
22
+ it 'returns information about the project' do
23
+ VCR.use_cassette('projects.get_list', record: :new_episodes) do
24
+ # result =
25
+ @projects.get_list
26
+ #result.name.should be_a String
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,21 @@
1
+ require 'spec_helper'
2
+
3
+ describe Paymo::Projects do
4
+
5
+ before(:all) do
6
+ VCR.use_cassette('auth') do
7
+ Paymo::Base.new(username: 'james@jamesduncombe.com', password: ENV['PAYMO_PASS'])
8
+ end
9
+ end
10
+
11
+ it 'returns a report' do
12
+ start_time = Time.new(2013, 5, 1)
13
+ end_time = Time.now
14
+ clients = '374101'
15
+ VCR.use_cassette('reports.create', record: :new_episodes) do
16
+ result = Paymo::Reports.new.create(clients: clients, start: start_time, end: end_time, include_entries: '1')
17
+ result['status'].should eq 'ok'
18
+ end
19
+ end
20
+
21
+ end
@@ -0,0 +1,15 @@
1
+
2
+ require 'rubygems'
3
+ require 'bundler/setup'
4
+ require 'webmock'
5
+ require 'vcr'
6
+ require 'paymo'
7
+
8
+ RSpec.configure do |config|
9
+ config.color_enabled = true
10
+ end
11
+
12
+ VCR.configure do |c|
13
+ c.cassette_library_dir = 'fixtures/vcr_cassettes'
14
+ c.hook_into :webmock
15
+ end
metadata ADDED
@@ -0,0 +1,87 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: paymo
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - James Duncombe
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-03-23 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rest-client
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.6'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.6'
27
+ description: Ruby wrapper for the Paymo API
28
+ email:
29
+ - james@jamesduncombe.com
30
+ executables: []
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - ".gitignore"
35
+ - ".travis.yml"
36
+ - Gemfile
37
+ - LICENSE
38
+ - README.md
39
+ - Rakefile
40
+ - lib/paymo.rb
41
+ - lib/paymo/api.rb
42
+ - lib/paymo/cache.rb
43
+ - lib/paymo/extras.rb
44
+ - lib/paymo/models/entry.rb
45
+ - lib/paymo/models/project.rb
46
+ - lib/paymo/resources/entries.rb
47
+ - lib/paymo/resources/projects.rb
48
+ - lib/paymo/resources/reports.rb
49
+ - lib/paymo/version.rb
50
+ - paymo.gemspec
51
+ - spec/lib/paymo/api_spec.rb
52
+ - spec/lib/paymo/extras_spec.rb
53
+ - spec/lib/paymo/resources/entries_spec.rb
54
+ - spec/lib/paymo/resources/projects_spec.rb
55
+ - spec/lib/paymo/resources/reports_spec.rb
56
+ - spec/spec_helper.rb
57
+ homepage: https://github.com/jamesduncombe/paymo
58
+ licenses:
59
+ - MIT
60
+ metadata: {}
61
+ post_install_message:
62
+ rdoc_options: []
63
+ require_paths:
64
+ - lib
65
+ required_ruby_version: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ required_rubygems_version: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
75
+ requirements: []
76
+ rubyforge_project:
77
+ rubygems_version: 2.2.2
78
+ signing_key:
79
+ specification_version: 4
80
+ summary: Simple way to interact with the Paymo API
81
+ test_files:
82
+ - spec/lib/paymo/api_spec.rb
83
+ - spec/lib/paymo/extras_spec.rb
84
+ - spec/lib/paymo/resources/entries_spec.rb
85
+ - spec/lib/paymo/resources/projects_spec.rb
86
+ - spec/lib/paymo/resources/reports_spec.rb
87
+ - spec/spec_helper.rb