attio-ruby 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.
Files changed (48) hide show
  1. checksums.yaml +7 -0
  2. data/.rspec +3 -0
  3. data/.rubocop.yml +164 -0
  4. data/.simplecov +17 -0
  5. data/.yardopts +9 -0
  6. data/CHANGELOG.md +27 -0
  7. data/CONTRIBUTING.md +333 -0
  8. data/INTEGRATION_TEST_STATUS.md +149 -0
  9. data/LICENSE +21 -0
  10. data/README.md +638 -0
  11. data/Rakefile +8 -0
  12. data/attio-ruby.gemspec +61 -0
  13. data/docs/CODECOV_SETUP.md +34 -0
  14. data/examples/basic_usage.rb +149 -0
  15. data/examples/oauth_flow.rb +843 -0
  16. data/examples/oauth_flow_README.md +84 -0
  17. data/examples/typed_records_example.rb +167 -0
  18. data/examples/webhook_server.rb +463 -0
  19. data/lib/attio/api_resource.rb +539 -0
  20. data/lib/attio/builders/name_builder.rb +181 -0
  21. data/lib/attio/client.rb +160 -0
  22. data/lib/attio/errors.rb +126 -0
  23. data/lib/attio/internal/record.rb +359 -0
  24. data/lib/attio/oauth/client.rb +219 -0
  25. data/lib/attio/oauth/scope_validator.rb +162 -0
  26. data/lib/attio/oauth/token.rb +158 -0
  27. data/lib/attio/resources/attribute.rb +332 -0
  28. data/lib/attio/resources/comment.rb +114 -0
  29. data/lib/attio/resources/company.rb +224 -0
  30. data/lib/attio/resources/entry.rb +208 -0
  31. data/lib/attio/resources/list.rb +196 -0
  32. data/lib/attio/resources/meta.rb +113 -0
  33. data/lib/attio/resources/note.rb +213 -0
  34. data/lib/attio/resources/object.rb +66 -0
  35. data/lib/attio/resources/person.rb +294 -0
  36. data/lib/attio/resources/task.rb +147 -0
  37. data/lib/attio/resources/thread.rb +99 -0
  38. data/lib/attio/resources/typed_record.rb +98 -0
  39. data/lib/attio/resources/webhook.rb +224 -0
  40. data/lib/attio/resources/workspace_member.rb +136 -0
  41. data/lib/attio/util/configuration.rb +166 -0
  42. data/lib/attio/util/id_extractor.rb +115 -0
  43. data/lib/attio/util/webhook_signature.rb +175 -0
  44. data/lib/attio/version.rb +6 -0
  45. data/lib/attio/webhook/event.rb +114 -0
  46. data/lib/attio/webhook/signature_verifier.rb +73 -0
  47. data/lib/attio.rb +123 -0
  48. metadata +402 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 30aee8e467a33e359480e61fbf740b7351fd63ebf985f32aa64108f4f5637617
4
+ data.tar.gz: 3c2ef27394c6d153233e43305ea1a2b714d8986194a966bd59fe755b1174321f
5
+ SHA512:
6
+ metadata.gz: bfb3bc04b4af46085f49a4852a049df7f61cb30c69d8689eed8d9e41f860650350eeb64409673be1c316c8131fefc54ee9ae00e48ef81c8481bce67f53e450d5
7
+ data.tar.gz: 2cac10e8790c90c75dac806f1e8575bc782c2c490acc185c51d31ff17bbaa055f6bf43faf1d3415b4d75bdf470de125d12b039dd03107d7702868b10391254ff
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,164 @@
1
+ inherit_gem:
2
+ standard: config/base.yml
3
+
4
+ require:
5
+ - standard
6
+ - rubocop-rspec
7
+
8
+ plugins:
9
+ - rubocop-performance
10
+
11
+ AllCops:
12
+ TargetRubyVersion: 3.3 # RuboCop doesn't support 3.4 yet, use 3.3
13
+ NewCops: enable
14
+ SuggestExtensions: false
15
+ Exclude:
16
+ - 'vendor/**/*'
17
+ - 'spec/fixtures/**/*'
18
+ - 'attio-ruby-*.gem'
19
+ - 'attio-ruby-*/**/*'
20
+
21
+ Style/StringLiterals:
22
+ EnforcedStyle: double_quotes
23
+
24
+ Metrics/MethodLength:
25
+ Max: 30
26
+ Exclude:
27
+ - 'spec/**/*'
28
+
29
+ Metrics/BlockLength:
30
+ Exclude:
31
+ - 'spec/**/*'
32
+ - '*.gemspec'
33
+
34
+ - 'examples/**/*'
35
+ - 'benchmarks/**/*'
36
+
37
+ Metrics/ClassLength:
38
+ Max: 200
39
+ Exclude:
40
+ - 'spec/**/*'
41
+
42
+ Metrics/AbcSize:
43
+ Max: 25
44
+ Exclude:
45
+ - 'spec/**/*'
46
+
47
+ Metrics/CyclomaticComplexity:
48
+ Max: 10
49
+
50
+ Metrics/PerceivedComplexity:
51
+ Max: 10
52
+
53
+ # Allow more parameters for API methods
54
+ Metrics/ParameterLists:
55
+ Max: 6
56
+
57
+ # API method naming conventions
58
+ Naming/PredicateName:
59
+ AllowedMethods:
60
+ - is_required
61
+ - is_unique
62
+ - has_more?
63
+ - has_scope?
64
+ - has_default?
65
+ - has_comments?
66
+ - destroy
67
+ - test
68
+ - validate!
69
+ - secure_compare
70
+ - delete
71
+ - revoke!
72
+
73
+
74
+ # Disable some cops for gemspec
75
+ Gemspec/DevelopmentDependencies:
76
+ Enabled: false
77
+
78
+ Gemspec/OrderedDependencies:
79
+ Enabled: false
80
+
81
+ # Documentation for simple modules is often unnecessary
82
+ Style/Documentation:
83
+ Enabled: false
84
+
85
+ # RSpec Configuration
86
+ RSpec/ExampleLength:
87
+ Max: 30
88
+ Exclude:
89
+ - 'spec/integration/**/*'
90
+
91
+ RSpec/MultipleExpectations:
92
+ Max: 10
93
+ Exclude:
94
+ - 'spec/integration/**/*'
95
+ - 'spec/unit/attio/errors_spec.rb'
96
+ - 'spec/unit/attio/resources/attribute_spec.rb'
97
+
98
+ RSpec/DescribeClass:
99
+ Exclude:
100
+ - 'spec/integration/**/*'
101
+ - 'spec/unit/attio/errors_spec.rb'
102
+
103
+ RSpec/MultipleMemoizedHelpers:
104
+ Max: 7
105
+
106
+ RSpec/MessageSpies:
107
+ Enabled: false
108
+
109
+ RSpec/VerifiedDoubles:
110
+ Enabled: false
111
+
112
+ RSpec/FilePath:
113
+ Enabled: false
114
+
115
+ RSpec/SpecFilePathFormat:
116
+ Enabled: false
117
+
118
+ RSpec/AnyInstance:
119
+ Enabled: false
120
+
121
+ RSpec/ContextWording:
122
+ Prefixes:
123
+ - when
124
+ - with
125
+ - without
126
+ - and
127
+
128
+ RSpec/IndexedLet:
129
+ Enabled: false
130
+
131
+ RSpec/MultipleDescribes:
132
+ Exclude:
133
+ - 'spec/unit/attio/errors_spec.rb'
134
+
135
+ RSpec/DescribeMethod:
136
+ Exclude:
137
+ - 'spec/unit/attio/errors_spec.rb'
138
+
139
+ # Disable Capybara cops as they're causing errors and we're not using Capybara
140
+ Capybara/RSpec/PredicateMatcher:
141
+ Enabled: false
142
+
143
+ # Allow global variables in examples
144
+ Style/GlobalVars:
145
+ Exclude:
146
+ - 'examples/**/*'
147
+
148
+ # Allow trailing whitespace to be fixed
149
+ Layout/TrailingWhitespace:
150
+ Enabled: true
151
+ AutoCorrect: true
152
+
153
+ # Allow trailing empty lines to be fixed
154
+ Layout/TrailingEmptyLines:
155
+ Enabled: true
156
+ AutoCorrect: true
157
+
158
+ # Performance cops configuration
159
+ Performance/CollectionLiteralInLoop:
160
+ Exclude:
161
+ - 'spec/**/*'
162
+
163
+ RSpec/NoExpectationExample:
164
+ Enabled: false
data/.simplecov ADDED
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "simplecov-cobertura"
4
+
5
+ SimpleCov.start do
6
+ add_filter "/spec/"
7
+ add_filter "/vendor/"
8
+
9
+ # Generate both HTML and XML coverage reports
10
+ formatter SimpleCov::Formatter::MultiFormatter.new([
11
+ SimpleCov::Formatter::HTMLFormatter,
12
+ SimpleCov::Formatter::CoberturaFormatter
13
+ ])
14
+
15
+ # Set coverage directory
16
+ coverage_dir "coverage"
17
+ end
data/.yardopts ADDED
@@ -0,0 +1,9 @@
1
+ --no-private
2
+ --markup markdown
3
+ --markup-provider redcarpet
4
+ --title "Attio Ruby SDK Documentation"
5
+ --output-dir doc
6
+ --readme README.md
7
+ --files CHANGELOG.md,CONTRIBUTING.md
8
+ lib/**/*.rb
9
+ examples/**/*.rb
data/CHANGELOG.md ADDED
@@ -0,0 +1,27 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [0.1.0] - 2025-07-27
9
+
10
+ ### Added
11
+ - Initial release of the Attio Ruby SDK
12
+ - Complete implementation of all Attio API v2 resources:
13
+ - Records (create, read, update, delete, list with filtering/sorting)
14
+ - Lists and List Entries
15
+ - Objects and Attributes
16
+ - Notes
17
+ - Tasks
18
+ - Comments and Threads
19
+ - Webhooks with signature verification
20
+ - Workspace Members
21
+ - OAuth 2.0 authentication support
22
+ - Thread-safe configuration management
23
+ - Comprehensive error handling with specific error types
24
+ - Webhook signature verification for security
25
+ - VCR-based test suite with high coverage
26
+ - Detailed documentation and examples
27
+ - Support for Ruby 3.4+
data/CONTRIBUTING.md ADDED
@@ -0,0 +1,333 @@
1
+ # Contributing to Attio Ruby SDK
2
+
3
+ First off, thank you for considering contributing to the Attio Ruby SDK! It's people like you that make this SDK a great tool for the Ruby community.
4
+
5
+ ## Table of Contents
6
+
7
+ - [Code of Conduct](#code-of-conduct)
8
+ - [Getting Started](#getting-started)
9
+ - [How Can I Contribute?](#how-can-i-contribute)
10
+ - [Reporting Bugs](#reporting-bugs)
11
+ - [Suggesting Enhancements](#suggesting-enhancements)
12
+ - [Pull Requests](#pull-requests)
13
+ - [Development Setup](#development-setup)
14
+ - [Style Guide](#style-guide)
15
+ - [Testing](#testing)
16
+ - [Documentation](#documentation)
17
+ - [Release Process](#release-process)
18
+
19
+ ## Code of Conduct
20
+
21
+ This project and everyone participating in it is governed by our Code of Conduct. By participating, you are expected to uphold this code.
22
+
23
+ ## Getting Started
24
+
25
+ 1. Fork the repository on GitHub
26
+ 2. Clone your fork locally
27
+ 3. Set up your development environment (see [Development Setup](#development-setup))
28
+ 4. Create a branch for your changes
29
+ 5. Make your changes
30
+ 6. Add tests for your changes
31
+ 7. Ensure all tests pass
32
+ 8. Submit a pull request
33
+
34
+ ## How Can I Contribute?
35
+
36
+ ### Reporting Bugs
37
+
38
+ Before creating bug reports, please check existing issues as you might find out that you don't need to create one. When you are creating a bug report, please include as many details as possible:
39
+
40
+ **Bug Report Template:**
41
+
42
+ ```markdown
43
+ **Description**
44
+ A clear and concise description of what the bug is.
45
+
46
+ **To Reproduce**
47
+ Steps to reproduce the behavior:
48
+ 1. Configure the client with '...'
49
+ 2. Call method '....'
50
+ 3. See error
51
+
52
+ **Expected behavior**
53
+ A clear and concise description of what you expected to happen.
54
+
55
+ **Actual behavior**
56
+ What actually happened, including any error messages.
57
+
58
+ **Environment:**
59
+ - Ruby version: [e.g. 3.1.0]
60
+ - Gem version: [e.g. 1.0.0]
61
+ - OS: [e.g. macOS 12.0]
62
+
63
+ **Additional context**
64
+ Add any other context about the problem here.
65
+ ```
66
+
67
+ ### Suggesting Enhancements
68
+
69
+ Enhancement suggestions are tracked as GitHub issues. When creating an enhancement suggestion, please include:
70
+
71
+ - A clear and descriptive title
72
+ - A detailed description of the proposed enhancement
73
+ - Explain why this enhancement would be useful
74
+ - List any alternatives you've considered
75
+ - Provide examples of how the feature would be used
76
+
77
+ ### Pull Requests
78
+
79
+ 1. Ensure your code follows the [Style Guide](#style-guide)
80
+ 2. Include appropriate test coverage
81
+ 3. Update documentation as needed
82
+ 4. Add a changelog entry in the Unreleased section
83
+ 5. Ensure CI passes on your pull request
84
+ 6. Request review from maintainers
85
+
86
+ **Pull Request Template:**
87
+
88
+ ```markdown
89
+ **Description**
90
+ Brief description of the changes in this PR.
91
+
92
+ **Motivation and Context**
93
+ Why is this change required? What problem does it solve?
94
+ Fixes #(issue)
95
+
96
+ **How Has This Been Tested?**
97
+ Describe the tests that you ran to verify your changes.
98
+
99
+ **Types of changes**
100
+ - [ ] Bug fix (non-breaking change which fixes an issue)
101
+ - [ ] New feature (non-breaking change which adds functionality)
102
+ - [ ] Breaking change (fix or feature that would cause existing functionality to change)
103
+
104
+ **Checklist:**
105
+ - [ ] My code follows the code style of this project
106
+ - [ ] My change requires a change to the documentation
107
+ - [ ] I have updated the documentation accordingly
108
+ - [ ] I have added tests to cover my changes
109
+ - [ ] All new and existing tests passed
110
+ ```
111
+
112
+ ## Development Setup
113
+
114
+ 1. **Install Ruby**
115
+ ```bash
116
+ rbenv install 3.1.0 # or use your preferred Ruby version manager
117
+ rbenv local 3.1.0
118
+ ```
119
+
120
+ 2. **Clone and setup the repository**
121
+ ```bash
122
+ git clone https://github.com/rbeene/attio_ruby.git
123
+ cd attio_ruby
124
+ bundle install
125
+ ```
126
+
127
+ 3. **Set up environment variables**
128
+ ```bash
129
+ # Create a .env file with your test API credentials
130
+ echo "ATTIO_API_KEY=your_test_api_key" > .env
131
+ ```
132
+
133
+ 4. **Run tests to verify setup**
134
+ ```bash
135
+ bundle exec rspec
136
+ ```
137
+
138
+ 5. **Start development console**
139
+ ```bash
140
+ bin/console
141
+ ```
142
+
143
+ ## Style Guide
144
+
145
+ ### Ruby Style
146
+
147
+ We use RuboCop to enforce consistent code style. Run RuboCop before submitting:
148
+
149
+ ```bash
150
+ bundle exec rubocop
151
+ bundle exec rubocop -a # Auto-fix violations
152
+ ```
153
+
154
+ Key style points:
155
+ - Use 2 spaces for indentation (no tabs)
156
+ - Use snake_case for variables and methods
157
+ - Use CamelCase for classes and modules
158
+ - Limit lines to 100 characters
159
+ - Use meaningful variable and method names
160
+ - Add frozen string literal comments to all files
161
+
162
+ ### Git Commit Messages
163
+
164
+ - Use the present tense ("Add feature" not "Added feature")
165
+ - Use the imperative mood ("Move cursor to..." not "Moves cursor to...")
166
+ - Limit the first line to 72 characters or less
167
+ - Reference issues and pull requests liberally after the first line
168
+
169
+ Example:
170
+ ```
171
+ Add batch update support for records
172
+
173
+ - Implement update_batch method in Record class
174
+ - Add progress callback support
175
+ - Include comprehensive error handling
176
+ - Add tests for edge cases
177
+
178
+ Fixes #123
179
+ ```
180
+
181
+ ## Testing
182
+
183
+ ### Running Tests
184
+
185
+ ```bash
186
+ # Run all tests
187
+ bundle exec rspec
188
+
189
+ # Run specific test file
190
+ bundle exec rspec spec/unit/resources/record_spec.rb
191
+
192
+ # Run tests matching a pattern
193
+ bundle exec rspec -e "batch operations"
194
+
195
+ # Run with coverage report
196
+ COVERAGE=true bundle exec rspec
197
+ ```
198
+
199
+ ### Writing Tests
200
+
201
+ - Write unit tests for all new functionality
202
+ - Aim for 100% code coverage for new code
203
+ - Use descriptive test names that explain what is being tested
204
+ - Group related tests using `describe` and `context`
205
+ - Use `let` and `subject` to reduce duplication
206
+ - Mock external API calls in unit tests
207
+
208
+ Example test structure:
209
+ ```ruby
210
+ RSpec.describe Attio::Record do
211
+ describe ".create" do
212
+ context "with valid parameters" do
213
+ it "creates a new record" do
214
+ # test implementation
215
+ end
216
+ end
217
+
218
+ context "with invalid parameters" do
219
+ it "raises InvalidRequestError" do
220
+ # test implementation
221
+ end
222
+ end
223
+ end
224
+ end
225
+ ```
226
+
227
+ ### Integration Tests
228
+
229
+ Integration tests require a valid API key:
230
+
231
+ ```bash
232
+ ATTIO_API_KEY=your_test_key RUN_INTEGRATION_TESTS=true bundle exec rspec spec/integration
233
+ ```
234
+
235
+ **Important:** Never commit real API keys. Use test/sandbox accounts for integration tests.
236
+
237
+ ## Documentation
238
+
239
+ ### Code Documentation
240
+
241
+ We use YARD for API documentation. Document all public methods:
242
+
243
+ ```ruby
244
+ # Creates a new record in the specified object
245
+ #
246
+ # @param object [String] The API slug of the object (e.g., "people", "companies")
247
+ # @param values [Hash] The attribute values for the new record
248
+ # @param opts [Hash] Additional options for the request
249
+ # @option opts [String] :api_key Override the default API key
250
+ # @option opts [Integer] :timeout Override the default timeout
251
+ #
252
+ # @return [Attio::Record] The created record
253
+ #
254
+ # @raise [Attio::Errors::InvalidRequestError] If the values are invalid
255
+ # @raise [Attio::Errors::NotFoundError] If the object doesn't exist
256
+ #
257
+ # @example Create a new person
258
+ # person = Attio::Record.create(
259
+ # object: "people",
260
+ # values: {
261
+ # name: "John Doe",
262
+ # email_addresses: "john@example.com"
263
+ # }
264
+ # )
265
+ def self.create(object:, values:, opts: {})
266
+ # implementation
267
+ end
268
+ ```
269
+
270
+ Generate documentation:
271
+ ```bash
272
+ bundle exec yard doc
273
+ open doc/index.html
274
+ ```
275
+
276
+ ### README Updates
277
+
278
+ Update the README when adding:
279
+ - New features
280
+ - Breaking changes
281
+ - Configuration options
282
+ - Usage examples
283
+
284
+ ## Release Process
285
+
286
+ 1. **Update version number**
287
+ ```ruby
288
+ # lib/attio/version.rb
289
+ module Attio
290
+ VERSION = "0.2.0" # Follow semantic versioning
291
+ end
292
+ ```
293
+
294
+ 2. **Update CHANGELOG.md**
295
+ - Move unreleased changes to a new version section
296
+ - Add release date
297
+ - Follow [Keep a Changelog](https://keepachangelog.com/) format
298
+
299
+ 3. **Create release commit**
300
+ ```bash
301
+ git add -A
302
+ git commit -m "Release version 0.2.0"
303
+ git push origin main
304
+ ```
305
+
306
+ 4. **Create and push tag**
307
+ ```bash
308
+ git tag -a v0.2.0 -m "Release version 0.2.0"
309
+ git push origin v0.2.0
310
+ ```
311
+
312
+ 5. **Build and release gem**
313
+ ```bash
314
+ gem build attio-ruby.gemspec
315
+ gem push attio-ruby-0.2.0.gem
316
+ ```
317
+
318
+ 6. **Create GitHub release**
319
+ - Go to GitHub releases page
320
+ - Create release from tag
321
+ - Copy changelog entries
322
+ - Publish release
323
+
324
+ ## Questions?
325
+
326
+ If you have questions about contributing, please:
327
+
328
+ 1. Check existing issues and pull requests
329
+ 2. Review the documentation
330
+ 3. Open a discussion on GitHub
331
+ 4. Contact the maintainers
332
+
333
+ Thank you for contributing to the Attio Ruby SDK!