moco-ruby 1.1.0 → 1.2.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.
Files changed (62) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +36 -1
  3. data/Gemfile.lock +44 -40
  4. data/README.md +53 -24
  5. data/lib/moco/client.rb +58 -0
  6. data/lib/moco/connection.rb +45 -22
  7. data/lib/moco/entities/activity.rb +31 -1
  8. data/lib/moco/entities/catalog_service.rb +54 -0
  9. data/lib/moco/entities/comment.rb +61 -0
  10. data/lib/moco/entities/company.rb +57 -2
  11. data/lib/moco/entities/contact.rb +56 -0
  12. data/lib/moco/entities/custom_property.rb +49 -0
  13. data/lib/moco/entities/deal.rb +38 -2
  14. data/lib/moco/entities/deal_category.rb +27 -0
  15. data/lib/moco/entities/employment.rb +55 -0
  16. data/lib/moco/entities/expense.rb +37 -2
  17. data/lib/moco/entities/expense_template.rb +39 -0
  18. data/lib/moco/entities/fixed_cost.rb +30 -0
  19. data/lib/moco/entities/holiday.rb +33 -2
  20. data/lib/moco/entities/hourly_rate.rb +33 -0
  21. data/lib/moco/entities/internal_hourly_rate.rb +32 -0
  22. data/lib/moco/entities/invoice.rb +81 -1
  23. data/lib/moco/entities/invoice_bookkeeping_export.rb +33 -0
  24. data/lib/moco/entities/invoice_payment.rb +51 -0
  25. data/lib/moco/entities/invoice_reminder.rb +51 -0
  26. data/lib/moco/entities/offer.rb +122 -0
  27. data/lib/moco/entities/offer_approval.rb +42 -0
  28. data/lib/moco/entities/payment_schedule.rb +48 -0
  29. data/lib/moco/entities/planning_entry.rb +43 -2
  30. data/lib/moco/entities/presence.rb +34 -2
  31. data/lib/moco/entities/profile.rb +24 -0
  32. data/lib/moco/entities/project.rb +76 -10
  33. data/lib/moco/entities/project_contract.rb +50 -0
  34. data/lib/moco/entities/project_group.rb +38 -0
  35. data/lib/moco/entities/purchase.rb +90 -0
  36. data/lib/moco/entities/purchase_bookkeeping_export.rb +34 -0
  37. data/lib/moco/entities/purchase_budget.rb +47 -0
  38. data/lib/moco/entities/purchase_category.rb +38 -0
  39. data/lib/moco/entities/purchase_draft.rb +25 -0
  40. data/lib/moco/entities/purchase_payment.rb +51 -0
  41. data/lib/moco/entities/receipt.rb +55 -0
  42. data/lib/moco/entities/recurring_expense.rb +55 -0
  43. data/lib/moco/entities/reports/absences.rb +16 -0
  44. data/lib/moco/entities/reports/cashflow.rb +16 -0
  45. data/lib/moco/entities/reports/finance.rb +16 -0
  46. data/lib/moco/entities/reports/utilization.rb +16 -0
  47. data/lib/moco/entities/schedule.rb +39 -2
  48. data/lib/moco/entities/tag.rb +30 -0
  49. data/lib/moco/entities/tagging.rb +27 -0
  50. data/lib/moco/entities/task.rb +25 -2
  51. data/lib/moco/entities/task_template.rb +38 -0
  52. data/lib/moco/entities/unit.rb +36 -0
  53. data/lib/moco/entities/user.rb +50 -2
  54. data/lib/moco/entities/user_role.rb +29 -0
  55. data/lib/moco/entities/vat_code_purchase.rb +29 -0
  56. data/lib/moco/entities/vat_code_sale.rb +29 -0
  57. data/lib/moco/entities/web_hook.rb +32 -2
  58. data/lib/moco/entities/work_time_adjustment.rb +51 -0
  59. data/lib/moco/version.rb +1 -1
  60. data/lib/moco.rb +51 -1
  61. data/moco.gemspec +38 -0
  62. metadata +47 -8
@@ -1,8 +1,44 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module MOCO
4
- # Represents a MOCO user
5
- # Provides methods for user-specific operations and associations
4
+ # Represents a MOCO user (staff member)
5
+ #
6
+ # == Required attributes for create:
7
+ # firstname - String, first name
8
+ # lastname - String, last name
9
+ # email - String, email address (used for login)
10
+ # unit_id - Integer, team/unit ID
11
+ #
12
+ # == Optional attributes:
13
+ # password - String, initial password (if not set, user gets welcome email)
14
+ # role_id - Integer, permission role ID
15
+ # active - Boolean, whether user is active
16
+ # external - Boolean, true for contractors/external staff
17
+ # language - String, one of: "de", "de-AT", "de-CH", "en", "it", "fr"
18
+ # mobile_phone - String, mobile phone number
19
+ # work_phone - String, work phone number
20
+ # home_address - String, home address (use \n for line breaks)
21
+ # bday - String, birthday "YYYY-MM-DD"
22
+ # iban - String, bank account IBAN
23
+ # tags - Array of Strings, e.g., ["Developer", "Remote"]
24
+ # custom_properties - Hash, e.g., {"Start Date": "2024-01-01"}
25
+ # info - String, additional notes
26
+ # welcome_email - Boolean, send welcome email (default: true if no password)
27
+ # avatar - Hash, { filename: "photo.jpg", base64: "..." }
28
+ #
29
+ # == Read-only attributes:
30
+ # id, avatar_url, unit (Hash), role (Hash), created_at, updated_at
31
+ #
32
+ # == Example:
33
+ # moco.users.create(
34
+ # firstname: "John",
35
+ # lastname: "Doe",
36
+ # email: "john.doe@company.com",
37
+ # unit_id: 123,
38
+ # language: "en",
39
+ # tags: ["Developer"]
40
+ # )
41
+ #
6
42
  class User < BaseEntity
7
43
  # Instance methods for user-specific operations
8
44
  def performance_report
@@ -22,6 +58,18 @@ module MOCO
22
58
  has_many(:holidays)
23
59
  end
24
60
 
61
+ def employments
62
+ has_many(:employments)
63
+ end
64
+
65
+ def work_time_adjustments
66
+ has_many(:work_time_adjustments)
67
+ end
68
+
69
+ def unit
70
+ association(:unit)
71
+ end
72
+
25
73
  def full_name
26
74
  "#{firstname} #{lastname}"
27
75
  end
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ module MOCO
4
+ # Represents a MOCO user permission role
5
+ # Read-only list of available permission roles
6
+ #
7
+ # == Read-only attributes:
8
+ # id, name, created_at, updated_at
9
+ #
10
+ # == Common roles:
11
+ # - Admin
12
+ # - Manager
13
+ # - Coworker
14
+ # - etc.
15
+ #
16
+ # == Note:
17
+ # Permission roles are configured in MOCO's admin interface.
18
+ # Use role_id when creating/updating users to assign a role.
19
+ #
20
+ class UserRole < BaseEntity
21
+ def self.entity_path
22
+ "users/roles"
23
+ end
24
+
25
+ def to_s
26
+ name.to_s
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ module MOCO
4
+ # Represents a MOCO purchase VAT code (Steuerschlüssel Einkauf)
5
+ # Read-only VAT rates for purchases/receipts
6
+ #
7
+ # == Read-only attributes:
8
+ # id, code, tax, reverse_charge, intra_eu, active
9
+ #
10
+ # == Filtering:
11
+ # moco.vat_code_purchases.where(active: true)
12
+ # moco.vat_code_purchases.where(reverse_charge: true)
13
+ # moco.vat_code_purchases.where(intra_eu: true)
14
+ # moco.vat_code_purchases.where(ids: "123,456")
15
+ #
16
+ # == Note:
17
+ # VAT codes are configured in MOCO's admin interface.
18
+ # Use vat_code_id when creating purchases/receipts.
19
+ #
20
+ class VatCodePurchase < BaseEntity
21
+ def self.entity_path
22
+ "vat_code_purchases"
23
+ end
24
+
25
+ def to_s
26
+ "#{code} - #{name}"
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ module MOCO
4
+ # Represents a MOCO sales VAT code (Steuerschlüssel Verkauf)
5
+ # Read-only VAT rates for invoices/offers
6
+ #
7
+ # == Read-only attributes:
8
+ # id, code, tax, reverse_charge, intra_eu, active,
9
+ # print_gross_total, notice_tax_exemption, credit_account
10
+ #
11
+ # == Filtering:
12
+ # moco.vat_code_sales.where(active: true)
13
+ # moco.vat_code_sales.where(reverse_charge: true)
14
+ # moco.vat_code_sales.where(intra_eu: true) # EU intra-community
15
+ #
16
+ # == Note:
17
+ # VAT codes are configured in MOCO's admin interface.
18
+ # Use vat_code_id when creating invoices/offers.
19
+ #
20
+ class VatCodeSale < BaseEntity
21
+ def self.entity_path
22
+ "vat_code_sales"
23
+ end
24
+
25
+ def to_s
26
+ "#{code} - #{name}"
27
+ end
28
+ end
29
+ end
@@ -1,8 +1,38 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module MOCO
4
- # Represents a MOCO webhook
5
- # Provides methods for webhook-specific operations
4
+ # Represents a MOCO webhook for event notifications
5
+ #
6
+ # == Required attributes for create:
7
+ # target - String, entity type to watch:
8
+ # "Activity", "Company", "Contact", "Project",
9
+ # "Invoice", "Offer", "Deal", "Expense"
10
+ # event - String, event type: "create", "update", "delete"
11
+ # hook - String, URL to receive webhook payloads (e.g., "https://example.org/callback")
12
+ #
13
+ # == Read-only attributes:
14
+ # id, disabled, disabled_at, created_at, updated_at
15
+ #
16
+ # == Instance methods:
17
+ # enable - Enable the webhook
18
+ # disable - Disable the webhook
19
+ #
20
+ # == Example:
21
+ # # Create webhook for new activities
22
+ # moco.web_hooks.create(
23
+ # target: "Activity",
24
+ # event: "create",
25
+ # hook: "https://example.org/moco-activity-webhook"
26
+ # )
27
+ #
28
+ # # Disable a webhook
29
+ # webhook = moco.web_hooks.find(123)
30
+ # webhook.disable
31
+ #
32
+ # == Note:
33
+ # Only the `hook` URL can be updated after creation.
34
+ # To change target/event, delete and recreate the webhook.
35
+ #
6
36
  class WebHook < BaseEntity
7
37
  # Override entity_path to match API path
8
38
  def self.entity_path
@@ -0,0 +1,51 @@
1
+ # frozen_string_literal: true
2
+
3
+ module MOCO
4
+ # Represents a MOCO user work time adjustment record
5
+ # (Korrekturen Zeiterfassung) for overtime/undertime corrections
6
+ #
7
+ # == Required attributes for create:
8
+ # user_id - Integer, user to adjust
9
+ # date - String, "YYYY-MM-DD" effective date
10
+ # description - String, reason for adjustment
11
+ # hours - Float, hours to add (positive) or subtract (negative)
12
+ #
13
+ # == Read-only attributes:
14
+ # id, user (Hash), creator (Hash), created_at, updated_at
15
+ #
16
+ # == Example:
17
+ # # Add overtime from previous year
18
+ # moco.work_time_adjustments.create(
19
+ # user_id: 123,
20
+ # date: "2024-01-01",
21
+ # description: "Overtime carryover from 2023",
22
+ # hours: 42.0
23
+ # )
24
+ #
25
+ # # Correct time balance
26
+ # moco.work_time_adjustments.create(
27
+ # user_id: 123,
28
+ # date: "2024-06-15",
29
+ # description: "Correction for unpaid leave",
30
+ # hours: -16.0
31
+ # )
32
+ #
33
+ # == Filtering:
34
+ # moco.work_time_adjustments.where(user_id: 123)
35
+ # moco.work_time_adjustments.where(from: "2024-01-01", to: "2024-12-31")
36
+ #
37
+ class WorkTimeAdjustment < BaseEntity
38
+ def self.entity_path
39
+ "users/work_time_adjustments"
40
+ end
41
+
42
+ # Associations
43
+ def user
44
+ association(:user)
45
+ end
46
+
47
+ def to_s
48
+ "WorkTimeAdjustment ##{id} (#{date})"
49
+ end
50
+ end
51
+ end
data/lib/moco/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module MOCO
4
- VERSION = "1.1.0"
4
+ VERSION = "1.2.0"
5
5
  end
data/lib/moco.rb CHANGED
@@ -11,8 +11,10 @@ require_relative "moco/connection"
11
11
  require_relative "moco/collection_proxy"
12
12
  require_relative "moco/nested_collection_proxy"
13
13
 
14
- # New API (v2)
14
+ # Entities
15
15
  require_relative "moco/entities/base_entity"
16
+
17
+ # Core entities (original)
16
18
  require_relative "moco/entities/project"
17
19
  require_relative "moco/entities/activity"
18
20
  require_relative "moco/entities/user"
@@ -26,6 +28,54 @@ require_relative "moco/entities/schedule"
26
28
  require_relative "moco/entities/presence"
27
29
  require_relative "moco/entities/holiday"
28
30
  require_relative "moco/entities/planning_entry"
31
+
32
+ # New standalone entities
33
+ require_relative "moco/entities/contact"
34
+ require_relative "moco/entities/offer"
35
+ require_relative "moco/entities/purchase"
36
+ require_relative "moco/entities/receipt"
37
+ require_relative "moco/entities/unit"
38
+ require_relative "moco/entities/comment"
39
+ require_relative "moco/entities/tag"
40
+ require_relative "moco/entities/tagging"
41
+ require_relative "moco/entities/deal_category"
42
+ require_relative "moco/entities/project_group"
43
+ require_relative "moco/entities/profile"
44
+
45
+ # Account-level entities
46
+ require_relative "moco/entities/catalog_service"
47
+ require_relative "moco/entities/custom_property"
48
+ require_relative "moco/entities/expense_template"
49
+ require_relative "moco/entities/fixed_cost"
50
+ require_relative "moco/entities/hourly_rate"
51
+ require_relative "moco/entities/internal_hourly_rate"
52
+ require_relative "moco/entities/task_template"
53
+ require_relative "moco/entities/user_role"
54
+ require_relative "moco/entities/vat_code_sale"
55
+ require_relative "moco/entities/vat_code_purchase"
56
+
57
+ # Nested/sub-resource entities
58
+ require_relative "moco/entities/employment"
59
+ require_relative "moco/entities/work_time_adjustment"
60
+ require_relative "moco/entities/project_contract"
61
+ require_relative "moco/entities/payment_schedule"
62
+ require_relative "moco/entities/recurring_expense"
63
+ require_relative "moco/entities/invoice_payment"
64
+ require_relative "moco/entities/invoice_reminder"
65
+ require_relative "moco/entities/invoice_bookkeeping_export"
66
+ require_relative "moco/entities/offer_approval"
67
+ require_relative "moco/entities/purchase_category"
68
+ require_relative "moco/entities/purchase_draft"
69
+ require_relative "moco/entities/purchase_payment"
70
+ require_relative "moco/entities/purchase_budget"
71
+ require_relative "moco/entities/purchase_bookkeeping_export"
72
+
73
+ # Reports
74
+ require_relative "moco/entities/reports/absences"
75
+ require_relative "moco/entities/reports/cashflow"
76
+ require_relative "moco/entities/reports/finance"
77
+ require_relative "moco/entities/reports/utilization"
78
+
29
79
  require_relative "moco/client"
30
80
  require_relative "moco/entity_collection"
31
81
 
data/moco.gemspec ADDED
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/moco/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "moco-ruby"
7
+ spec.version = MOCO::VERSION
8
+ spec.authors = ["Teal Bauer"]
9
+ spec.email = ["rubygems@teal.is"]
10
+
11
+ spec.summary = "A Ruby Gem to interact with the MOCO API."
12
+ spec.description = "A modern, Ruby-esque interface for the MOCO API (mocoapp.com). " \
13
+ "Provides an ActiveRecord-style interface for projects, activities, users, companies, and more."
14
+ spec.homepage = "https://github.com/starsong-consulting/moco-ruby"
15
+ spec.required_ruby_version = ">= 3.2.0"
16
+ spec.license = "Apache-2.0"
17
+
18
+ spec.metadata["homepage_uri"] = spec.homepage
19
+ spec.metadata["source_code_uri"] = "https://github.com/starsong-consulting/moco-ruby"
20
+ spec.metadata["changelog_uri"] = "https://github.com/starsong-consulting/moco-ruby/blob/main/CHANGELOG.md"
21
+
22
+ # Specify which files should be added to the gem when it is released.
23
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
24
+ spec.files = Dir.chdir(__dir__) do
25
+ `git ls-files -z`.split("\x0").reject do |f|
26
+ (f == __FILE__) || f.match(%r{\A(?:(?:bin|test|spec|features)/|\.(?:git|circleci)|appveyor)})
27
+ end
28
+ end
29
+ spec.bindir = "exe"
30
+ spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
31
+ spec.require_paths = ["lib"]
32
+
33
+ spec.add_dependency "activesupport", ">= 7.0"
34
+ spec.add_dependency "faraday", ">= 2.0"
35
+ spec.add_dependency "fuzzy_match", "~> 2.1.0"
36
+
37
+ spec.metadata["rubygems_mfa_required"] = "true"
38
+ end
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: moco-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Teal Bauer
8
- autorequire:
9
8
  bindir: exe
10
9
  cert_chain: []
11
- date: 2026-01-09 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: activesupport
@@ -52,7 +51,9 @@ dependencies:
52
51
  - - "~>"
53
52
  - !ruby/object:Gem::Version
54
53
  version: 2.1.0
55
- description:
54
+ description: A modern, Ruby-esque interface for the MOCO API (mocoapp.com). Provides
55
+ an ActiveRecord-style interface for projects, activities, users, companies, and
56
+ more.
56
57
  email:
57
58
  - rubygems@teal.is
58
59
  executables: []
@@ -79,23 +80,63 @@ files:
79
80
  - lib/moco/entities.rb
80
81
  - lib/moco/entities/activity.rb
81
82
  - lib/moco/entities/base_entity.rb
83
+ - lib/moco/entities/catalog_service.rb
84
+ - lib/moco/entities/comment.rb
82
85
  - lib/moco/entities/company.rb
86
+ - lib/moco/entities/contact.rb
87
+ - lib/moco/entities/custom_property.rb
83
88
  - lib/moco/entities/deal.rb
89
+ - lib/moco/entities/deal_category.rb
90
+ - lib/moco/entities/employment.rb
84
91
  - lib/moco/entities/expense.rb
92
+ - lib/moco/entities/expense_template.rb
93
+ - lib/moco/entities/fixed_cost.rb
85
94
  - lib/moco/entities/holiday.rb
95
+ - lib/moco/entities/hourly_rate.rb
96
+ - lib/moco/entities/internal_hourly_rate.rb
86
97
  - lib/moco/entities/invoice.rb
98
+ - lib/moco/entities/invoice_bookkeeping_export.rb
99
+ - lib/moco/entities/invoice_payment.rb
100
+ - lib/moco/entities/invoice_reminder.rb
101
+ - lib/moco/entities/offer.rb
102
+ - lib/moco/entities/offer_approval.rb
103
+ - lib/moco/entities/payment_schedule.rb
87
104
  - lib/moco/entities/planning_entry.rb
88
105
  - lib/moco/entities/presence.rb
106
+ - lib/moco/entities/profile.rb
89
107
  - lib/moco/entities/project.rb
108
+ - lib/moco/entities/project_contract.rb
109
+ - lib/moco/entities/project_group.rb
110
+ - lib/moco/entities/purchase.rb
111
+ - lib/moco/entities/purchase_bookkeeping_export.rb
112
+ - lib/moco/entities/purchase_budget.rb
113
+ - lib/moco/entities/purchase_category.rb
114
+ - lib/moco/entities/purchase_draft.rb
115
+ - lib/moco/entities/purchase_payment.rb
116
+ - lib/moco/entities/receipt.rb
117
+ - lib/moco/entities/recurring_expense.rb
118
+ - lib/moco/entities/reports/absences.rb
119
+ - lib/moco/entities/reports/cashflow.rb
120
+ - lib/moco/entities/reports/finance.rb
121
+ - lib/moco/entities/reports/utilization.rb
90
122
  - lib/moco/entities/schedule.rb
123
+ - lib/moco/entities/tag.rb
124
+ - lib/moco/entities/tagging.rb
91
125
  - lib/moco/entities/task.rb
126
+ - lib/moco/entities/task_template.rb
127
+ - lib/moco/entities/unit.rb
92
128
  - lib/moco/entities/user.rb
129
+ - lib/moco/entities/user_role.rb
130
+ - lib/moco/entities/vat_code_purchase.rb
131
+ - lib/moco/entities/vat_code_sale.rb
93
132
  - lib/moco/entities/web_hook.rb
133
+ - lib/moco/entities/work_time_adjustment.rb
94
134
  - lib/moco/entity_collection.rb
95
135
  - lib/moco/helpers.rb
96
136
  - lib/moco/nested_collection_proxy.rb
97
137
  - lib/moco/sync.rb
98
138
  - lib/moco/version.rb
139
+ - moco.gemspec
99
140
  - mocurl.rb
100
141
  - sync_activity.rb
101
142
  homepage: https://github.com/starsong-consulting/moco-ruby
@@ -106,7 +147,6 @@ metadata:
106
147
  source_code_uri: https://github.com/starsong-consulting/moco-ruby
107
148
  changelog_uri: https://github.com/starsong-consulting/moco-ruby/blob/main/CHANGELOG.md
108
149
  rubygems_mfa_required: 'true'
109
- post_install_message:
110
150
  rdoc_options: []
111
151
  require_paths:
112
152
  - lib
@@ -121,8 +161,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
121
161
  - !ruby/object:Gem::Version
122
162
  version: '0'
123
163
  requirements: []
124
- rubygems_version: 3.4.1
125
- signing_key:
164
+ rubygems_version: 4.0.3
126
165
  specification_version: 4
127
- summary: A Ruby Gem to interact with the MOCO (mocoapp.com) API.
166
+ summary: A Ruby Gem to interact with the MOCO API.
128
167
  test_files: []