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
@@ -0,0 +1,34 @@
1
+ # Codecov Setup
2
+
3
+ To enable code coverage reporting in CI:
4
+
5
+ 1. **Get a Codecov token**:
6
+ - Go to [codecov.io](https://codecov.io)
7
+ - Sign in with your GitHub account
8
+ - Add your repository
9
+ - Copy the repository token
10
+
11
+ 2. **Add the token to GitHub secrets**:
12
+ - Go to your repository on GitHub
13
+ - Navigate to Settings → Secrets and variables → Actions
14
+ - Click "New repository secret"
15
+ - Name: `CODECOV_TOKEN`
16
+ - Value: Paste your Codecov token
17
+ - Click "Add secret"
18
+
19
+ 3. **Coverage reports will be generated automatically**:
20
+ - The CI workflow runs tests with coverage enabled
21
+ - Coverage reports are uploaded to Codecov on push events
22
+ - Pull requests will show coverage information
23
+
24
+ ## Local Coverage
25
+
26
+ To generate coverage reports locally:
27
+
28
+ ```bash
29
+ COVERAGE=true bundle exec rspec
30
+ ```
31
+
32
+ This will generate:
33
+ - HTML report at `coverage/index.html`
34
+ - XML report at `coverage/coverage.xml` (for Codecov)
@@ -0,0 +1,149 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require "bundler/setup"
5
+ require "attio"
6
+ require "dotenv/load"
7
+
8
+ # Basic usage example for Attio Ruby gem
9
+
10
+ # Configure the client
11
+ Attio.configure do |config|
12
+ config.api_key = ENV.fetch("ATTIO_API_KEY", nil)
13
+ # Optional configurations
14
+ # config.api_base = "https://api.attio.com"
15
+ # config.timeout = 30
16
+ # config.debug = true
17
+ end
18
+
19
+ puts "=== Attio Ruby Gem Basic Usage Example ==="
20
+ puts
21
+
22
+ # 1. Working with Objects
23
+ puts "1. Listing Objects:"
24
+ objects = Attio::Object.list
25
+ objects.each do |object|
26
+ puts " - #{object.plural_noun} (#{object.api_slug})"
27
+ end
28
+ puts
29
+
30
+ # 2. Working with Records (People)
31
+ puts "2. Creating a Person:"
32
+ person = Attio::Record.create(
33
+ values: {
34
+ name: [{
35
+ first_name: "John",
36
+ last_name: "Doe",
37
+ full_name: "John Doe"
38
+ }],
39
+ email_addresses: ["john@example.com"],
40
+ phone_numbers: [{
41
+ original_phone_number: "+1-555-0123",
42
+ country_code: "US"
43
+ }],
44
+ job_title: "Software Engineer"
45
+ },
46
+ object: "people"
47
+ )
48
+ puts " Created: #{person[:name]} (ID: #{person.id})"
49
+ puts
50
+
51
+ # 3. Searching for Records
52
+ puts "3. Searching for People:"
53
+ people = Attio::Record.list(
54
+ {
55
+ q: "john",
56
+ limit: 5
57
+ },
58
+ object: "people"
59
+ )
60
+ puts " Found #{people.count} people matching 'john'"
61
+ people.each do |p|
62
+ puts " - #{p[:name]} (#{p[:email_addresses]})"
63
+ end
64
+ puts
65
+
66
+ # 4. Working with Companies
67
+ puts "4. Creating a Company:"
68
+ company = Attio::Record.create(
69
+ values: {
70
+ name: "Acme Corporation",
71
+ domains: ["acme.com"],
72
+ industry: "Technology",
73
+ company_size: "50-100"
74
+ },
75
+ object: "companies"
76
+ )
77
+ puts " Created: #{company[:name]} (ID: #{company.id})"
78
+ puts
79
+
80
+ # 5. Updating Records
81
+ puts "5. Updating a Record:"
82
+ person[:job_title] = "Senior Software Engineer"
83
+ person[:company] = [{target_object: "companies", target_record: company.id}]
84
+ person.save
85
+ puts " Updated #{person[:name]}'s job title and company"
86
+ puts
87
+
88
+ # 6. Working with Lists
89
+ puts "6. Creating and Managing Lists:"
90
+ list = Attio::List.create(
91
+ name: "VIP Customers",
92
+ object: "people"
93
+ )
94
+ puts " Created list: #{list.name}"
95
+
96
+ # Add person to list
97
+ list.add_record(person.id)
98
+ puts " Added #{person[:name]} to #{list.name}"
99
+ puts
100
+
101
+ # 7. Adding Notes
102
+ puts "7. Adding a Note:"
103
+ Attio::Note.create(
104
+ parent_object: "people",
105
+ parent_record_id: person.id,
106
+ content: "Had a great meeting about the new project. Very interested in our solution.",
107
+ format: "plaintext"
108
+ )
109
+ puts " Added note to #{person[:name]}'s record"
110
+ puts
111
+
112
+ # 8. Working with Attributes
113
+ puts "8. Listing Attributes for People:"
114
+ attributes = Attio::Attribute.list(object: "people")
115
+ puts " People object has #{attributes.count} attributes:"
116
+ attributes.first(5).each do |attr|
117
+ puts " - #{attr.name} (#{attr.type})"
118
+ end
119
+ puts
120
+
121
+ # 9. Working with Attributes
122
+ puts "9. Searching Records:"
123
+ # Search people by query
124
+ search_results = Attio::Record.list(
125
+ object: "people",
126
+ params: {q: "Jane"}
127
+ )
128
+ puts " Found #{search_results.count} people matching 'Jane'"
129
+ puts
130
+
131
+ # 10. Error Handling
132
+ puts "10. Error Handling Example:"
133
+ begin
134
+ # Try to create a record without required fields
135
+ Attio::Record.create(object: "invalid_object", values: {})
136
+ rescue Attio::Errors::NotFoundError => e
137
+ puts " Caught error: #{e.message}"
138
+ puts " Request ID: #{e.request_id}" if e.request_id
139
+ end
140
+ puts
141
+
142
+ puts "=== Example Complete ==="
143
+ puts "This example demonstrated:"
144
+ puts "- Configuring the client"
145
+ puts "- Creating and updating records"
146
+ puts "- Searching and filtering"
147
+ puts "- Working with lists and notes"
148
+ puts "- Working with attributes"
149
+ puts "- Error handling"