notion-sdk-ruby 0.2.2 → 0.4.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 876930491da71b978c0a95bb00e5d8838eb1ad4655489ab10d7d66e291708bba
4
- data.tar.gz: e4a1998ecbc4719fc3697fc0e562d31f59830d9f736a2b29e825a908fde368a1
3
+ metadata.gz: 2b8f9260f352a244eaf86cd39b5724c874929548ebf289f795755d2e63aa09b8
4
+ data.tar.gz: f7c63168582a3f7d7c0b898fb0bcd85338c26c816782cd8d222fde67c1418d80
5
5
  SHA512:
6
- metadata.gz: 318989ffe70cd56b2c91fa08ee04a265fd246cb0b36c9b0a1b72b78d60532159a30412ad2d0e74291af723dc1044acc19737692d2ccc10bf1c91c6830a2cf735
7
- data.tar.gz: d3e6a6101aeb1c53667c4402498c6b6594170d40fb84513c8375ca4371bbf1dc8600bb0ce28d7ca97c89daf371ae8948f91fafca9abc3b52f8590f1748510526
6
+ metadata.gz: f9e01092c18da58fb6d9e813cfdea77f96deb71295c525f7942cf7e125fd70106d4a33e414513fa2e6282849ea84787552397e6d009272480b11801c93509925
7
+ data.tar.gz: fcec5ce30ef130a1c54582cef9bd792729acb134c3b81a860a9b939f198fd115c79ef5d8ea4481723a6ee345b116cf9fb81b5aedf03d373cfab33853700e1543
@@ -0,0 +1,34 @@
1
+ # This workflow uses actions that are not certified by GitHub.
2
+ # They are provided by a third-party and are governed by
3
+ # separate terms of service, privacy policy, and support
4
+ # documentation.
5
+ # This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
6
+ # For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
7
+
8
+ name: ci
9
+
10
+ on:
11
+ push:
12
+ branches: [main]
13
+ pull_request:
14
+ branches: [main]
15
+
16
+ jobs:
17
+ test:
18
+ runs-on: ubuntu-latest
19
+ strategy:
20
+ matrix:
21
+ ruby-version: ["2.6", "2.7", "3.0"]
22
+
23
+ steps:
24
+ - uses: actions/checkout@v2
25
+ - name: Set up Ruby
26
+ # To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
27
+ # change this to (see https://github.com/ruby/setup-ruby#versioning):
28
+ # uses: ruby/setup-ruby@v1
29
+ uses: ruby/setup-ruby@473e4d8fe5dd94ee328fdfca9f8c9c7afc9dae5e
30
+ with:
31
+ ruby-version: ${{ matrix.ruby-version }}
32
+ bundler-cache: true # runs 'bundle install' and caches installed gems automatically
33
+ - name: Run tests
34
+ run: bundle exec rake
data/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
- source "https://rubygems.org"
2
-
3
- # Specify your gem's dependencies in notion-sdk-ruby.gemspec
4
- gemspec
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in notion-sdk-ruby.gemspec
4
+ gemspec
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- notion-sdk-ruby (0.2.2)
4
+ notion-sdk-ruby (0.4.0)
5
5
  httparty (~> 0.18.1)
6
6
 
7
7
  GEM
@@ -22,7 +22,7 @@ GEM
22
22
  method_source (1.0.0)
23
23
  mime-types (3.3.1)
24
24
  mime-types-data (~> 3.2015)
25
- mime-types-data (3.2021.0225)
25
+ mime-types-data (3.2021.0704)
26
26
  multi_xml (0.6.0)
27
27
  parallel (1.20.1)
28
28
  parser (3.0.1.1)
@@ -88,4 +88,4 @@ DEPENDENCIES
88
88
  webmock (~> 3.12)
89
89
 
90
90
  BUNDLED WITH
91
- 2.1.4
91
+ 2.2.3
data/README.md CHANGED
@@ -1,7 +1,34 @@
1
1
  # Notion Ruby SDK
2
2
 
3
+ [![ci](https://github.com/mgmarlow/notion-sdk-ruby/actions/workflows/ci.yml/badge.svg)](https://github.com/mgmarlow/notion-sdk-ruby/actions/workflows/ci.yml)
4
+ [![Gem Version](https://badge.fury.io/rb/notion-sdk-ruby.svg)](https://badge.fury.io/rb/notion-sdk-ruby)
5
+
3
6
  Unofficial Ruby client for the [Notion APIs](https://developers.notion.com/).
4
7
 
8
+ - [Notion Ruby SDK](#notion-ruby-sdk)
9
+ - [Installation](#installation)
10
+ - [Usage](#usage)
11
+ - [API reference](#api-reference)
12
+ - [Databases](#databases)
13
+ - [databases#retrieve](#databasesretrieve)
14
+ - [databases#list](#databaseslist)
15
+ - [databases#query](#databasesquery)
16
+ - [Pages](#pages)
17
+ - [pages#retrieve](#pagesretrieve)
18
+ - [pages#create](#pagescreate)
19
+ - [pages#update](#pagesupdate)
20
+ - [Blocks](#blocks)
21
+ - [blocks#children#list](#blockschildrenlist)
22
+ - [blocks#children#append](#blockschildrenappend)
23
+ - [Users](#users)
24
+ - [users#retrieve](#usersretrieve)
25
+ - [users#list](#userslist)
26
+ - [Search](#search)
27
+ - [#search](#search-1)
28
+ - [Development](#development)
29
+ - [Contributing](#contributing)
30
+ - [License](#license)
31
+
5
32
  ## Installation
6
33
 
7
34
  Add this line to your application's Gemfile:
@@ -14,10 +41,6 @@ And then execute:
14
41
 
15
42
  $ bundle install
16
43
 
17
- Or install it yourself as:
18
-
19
- $ gem install notion-sdk-ruby
20
-
21
44
  ## Usage
22
45
 
23
46
  Initialize `Notion::Client` with your app's [integration secret](https://developers.notion.com/docs/getting-started#create-a-new-integration).
@@ -25,29 +48,34 @@ Initialize `Notion::Client` with your app's [integration secret](https://develop
25
48
  ```rb
26
49
  require "notion-sdk-ruby"
27
50
  client = Notion::Client.new(token: ENV["NOTION_API_SECRET"])
28
-
29
- # get users
30
- client.get_users
31
51
  ```
32
52
 
53
+ ## API reference
54
+
33
55
  ### Databases
34
56
 
35
- #### #get_database
57
+ #### databases#retrieve
58
+
59
+ [API reference](https://developers.notion.com/reference/get-database)
36
60
 
37
61
  ```rb
38
- client.get_database("668d797c-76fa-4934-9b05-ad288df2d136")
62
+ client.databases.retrieve("668d797c-76fa-4934-9b05-ad288df2d136")
39
63
  ```
40
64
 
41
- #### #get_databases
65
+ #### databases#list
66
+
67
+ [API reference](https://developers.notion.com/reference/get-databases)
42
68
 
43
69
  ```rb
44
- client.get_databases
70
+ client.databases.list
45
71
  ```
46
72
 
47
- #### #query_database
73
+ #### databases#query
74
+
75
+ [API reference](https://developers.notion.com/reference/post-database-query)
48
76
 
49
77
  ```rb
50
- client.query_database("668d797c-76fa-4934-9b05-ad288df2d136", {
78
+ client.databases.query("668d797c-76fa-4934-9b05-ad288df2d136", {
51
79
  "filter": {
52
80
  "or": [
53
81
  {
@@ -75,16 +103,20 @@ client.query_database("668d797c-76fa-4934-9b05-ad288df2d136", {
75
103
 
76
104
  ### Pages
77
105
 
78
- #### #get_page
106
+ #### pages#retrieve
107
+
108
+ [API reference](https://developers.notion.com/reference/get-page)
79
109
 
80
110
  ```rb
81
- client.get_page("b55c9c91-384d-452b-81db-d1ef79372b75")
111
+ client.pages.retrieve("b55c9c91-384d-452b-81db-d1ef79372b75")
82
112
  ```
83
113
 
84
- #### #create_page
114
+ #### pages#create
115
+
116
+ [API reference](https://developers.notion.com/reference/post-page)
85
117
 
86
118
  ```rb
87
- client.create_page({
119
+ client.pages.create({
88
120
  "parent": { "database_id": "48f8fee9cd794180bc2fec0398253067" },
89
121
  "properties": {
90
122
  "Name": {
@@ -116,10 +148,12 @@ client.create_page({
116
148
  })
117
149
  ```
118
150
 
119
- #### #update_page
151
+ #### pages#update
152
+
153
+ [API reference](https://developers.notion.com/reference/patch-page)
120
154
 
121
155
  ```rb
122
- client.update_page("b55c9c91-384d-452b-81db-d1ef79372b75", {
156
+ client.pages.update("b55c9c91-384d-452b-81db-d1ef79372b75", {
123
157
  "properties": {
124
158
  "In stock": { "checkbox": true }
125
159
  }
@@ -128,18 +162,22 @@ client.update_page("b55c9c91-384d-452b-81db-d1ef79372b75", {
128
162
 
129
163
  ### Blocks
130
164
 
131
- #### #get_block_children
165
+ #### blocks#children#list
166
+
167
+ [API reference](https://developers.notion.com/reference/get-block-children)
132
168
 
133
169
  ```rb
134
- client.get_block_children("b55c9c91-384d-452b-81db-d1ef79372b75", {
170
+ client.blocks.children.list("b55c9c91-384d-452b-81db-d1ef79372b75", {
135
171
  page_size: 100
136
172
  })
137
173
  ```
138
174
 
139
- #### #append_block_children
175
+ #### blocks#children#append
176
+
177
+ [API reference](https://developers.notion.com/reference/patch-block-children)
140
178
 
141
179
  ```rb
142
- client.append_block_children("b54c9c91-384d-452b-81db-d1ef79372b75", {
180
+ client.blocks.children.append("b54c9c91-384d-452b-81db-d1ef79372b75", {
143
181
  "children": [
144
182
  {
145
183
  "object": "block",
@@ -169,20 +207,26 @@ client.append_block_children("b54c9c91-384d-452b-81db-d1ef79372b75", {
169
207
 
170
208
  ### Users
171
209
 
172
- #### #get_user
210
+ #### users#retrieve
211
+
212
+ [API reference](https://developers.notion.com/reference/get-user)
173
213
 
174
214
  ```rb
175
- client.get_user("d40e767c-d7af-4b18-a86d-55c61f1e39a4")
215
+ client.users.retrieve("d40e767c-d7af-4b18-a86d-55c61f1e39a4")
176
216
  ```
177
217
 
178
- #### #get_users
218
+ #### users#list
219
+
220
+ [API reference](https://developers.notion.com/reference/get-users)
179
221
 
180
222
  ```rb
181
- client.get_users
223
+ client.users.list
182
224
  ```
183
225
 
184
226
  ### Search
185
227
 
228
+ [API reference](https://developers.notion.com/reference/post-search)
229
+
186
230
  #### #search
187
231
 
188
232
  ```rb
@@ -200,6 +244,14 @@ client.search({
200
244
 
201
245
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
202
246
 
247
+ Before using `bin/console` you need to create a new file, `.env`, at the root project directory. This will enable you to run commands directly against your [Notion integration](https://developers.notion.com/docs/getting-started).
248
+
249
+ ```
250
+ cat > .env <<EOF
251
+ API_SECRET=<YOUR NOTION API SECRET HERE>
252
+ EOF
253
+ ```
254
+
203
255
  To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
204
256
 
205
257
  ## Contributing
data/Rakefile CHANGED
@@ -1,7 +1,7 @@
1
- require "bundler/gem_tasks"
2
- require "rspec/core/rake_task"
3
- require "standard/rake"
4
-
5
- RSpec::Core::RakeTask.new(:spec)
6
-
7
- task default: [:spec, :standard]
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+ require "standard/rake"
4
+
5
+ RSpec::Core::RakeTask.new(:spec)
6
+
7
+ task default: [:spec, :standard]
data/bin/console CHANGED
@@ -4,7 +4,7 @@ require "bundler/setup"
4
4
  require "pry"
5
5
  require 'dotenv/load'
6
6
 
7
- require "notion"
7
+ require "notion-sdk-ruby"
8
8
 
9
9
  $client = Notion::Client.new(token: ENV["API_SECRET"])
10
10
 
@@ -0,0 +1,27 @@
1
+ require "httparty"
2
+ require "forwardable"
3
+
4
+ require "notion-sdk-ruby/version"
5
+
6
+ require "notion-sdk-ruby/config"
7
+ require "notion-sdk-ruby/resources/blocks"
8
+ require "notion-sdk-ruby/resources/databases"
9
+ require "notion-sdk-ruby/resources/pages"
10
+ require "notion-sdk-ruby/resources/users"
11
+ require "notion-sdk-ruby/operations/search"
12
+ require "notion-sdk-ruby/error"
13
+ require "notion-sdk-ruby/request_client"
14
+ require "notion-sdk-ruby/client"
15
+
16
+ module Notion
17
+ @config = Config.new
18
+
19
+ class << self
20
+ extend Forwardable
21
+
22
+ attr_reader :config
23
+
24
+ def_delegators :@config, :api_token, :api_token=
25
+ def_delegators :@config, :notion_version, :notion_version=
26
+ end
27
+ end
@@ -0,0 +1,26 @@
1
+ module Notion
2
+ class Client
3
+ include Operations::Search
4
+
5
+ def initialize(token:, notion_version: "2021-05-13")
6
+ Notion.api_token = token
7
+ Notion.notion_version = notion_version
8
+ end
9
+
10
+ def blocks
11
+ Blocks.new
12
+ end
13
+
14
+ def databases
15
+ Databases.new
16
+ end
17
+
18
+ def pages
19
+ Pages.new
20
+ end
21
+
22
+ def users
23
+ Users.new
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,5 @@
1
+ module Notion
2
+ class Config
3
+ attr_accessor :api_token, :notion_version
4
+ end
5
+ end
@@ -0,0 +1,52 @@
1
+ # Sourced from notion-sdk-js:
2
+ # https://github.com/makenotion/notion-sdk-js/blob/main/src/errors.ts
3
+ module Notion
4
+ API_ERROR_CODE = {
5
+ unauthorized: "unauthorized",
6
+ restricted_resource: "restricted_resource",
7
+ object_not_found: "object_not_found",
8
+ rate_limited: "rate_limited",
9
+ invalid_json: "invalid_json",
10
+ invalid_request_url: "invalid_request_url",
11
+ invalid_request: "invalid_request",
12
+ validation_error: "validation_error",
13
+ conflict_error: "conflict_error",
14
+ internal_server_error: "internal_server_error",
15
+ service_unavailable: "service_unavailable"
16
+ }
17
+
18
+ class ErrorFactory
19
+ def self.create(error = {})
20
+ return NotionError.new("Unknown error.") if error["message"].nil?
21
+
22
+ if API_ERROR_CODE.value?(error["code"])
23
+ APIResponseError.new(error["message"], body: error)
24
+ elsif error["request"] && error["response"] && error["timings"]
25
+ HTTPResponseError.new(error["message"], body: error)
26
+ elsif error["request"] && error["timings"]
27
+ RequestTimeoutError.new(error["message"], body: error)
28
+ else
29
+ NotionError.new(error["message"])
30
+ end
31
+ end
32
+ end
33
+
34
+ class NotionError < StandardError
35
+ attr_reader :message, :body
36
+
37
+ def initialize(message = nil, body: nil)
38
+ @message = message
39
+ @body = body
40
+ end
41
+ end
42
+
43
+ class RequestTimeoutError < NotionError; end
44
+
45
+ class HTTPResponseError < NotionError; end
46
+
47
+ class APIResponseError < NotionError
48
+ def code
49
+ body["code"]
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,9 @@
1
+ module Notion
2
+ module Operations
3
+ module Search
4
+ def search(body)
5
+ RequestClient.active_client.post("/v1/search", body: body.to_json)
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,50 @@
1
+ module Notion
2
+ class RequestClient
3
+ include HTTParty
4
+
5
+ base_uri "https://api.notion.com"
6
+ headers "Content-Type": "application/json"
7
+
8
+ def self.active_client
9
+ RequestClient.new(Notion.config)
10
+ end
11
+
12
+ def initialize(config)
13
+ self.class.headers Authorization: "Bearer #{config.api_token}"
14
+ self.class.headers "Notion-Version": config.notion_version
15
+ end
16
+
17
+ def get(*args, &block)
18
+ response = self.class.get(*args, &block)
19
+ raise_on_failure(response)
20
+ end
21
+
22
+ def post(*args, &block)
23
+ response = self.class.post(*args, &block)
24
+ raise_on_failure(response)
25
+ end
26
+
27
+ def patch(*args, &block)
28
+ response = self.class.patch(*args, &block)
29
+ raise_on_failure(response)
30
+ end
31
+
32
+ def put(*args, &block)
33
+ response = self.class.put(*args, &block)
34
+ raise_on_failure(response)
35
+ end
36
+
37
+ def delete(*args, &block)
38
+ response = self.class.delete(*args, &block)
39
+ raise_on_failure(response)
40
+ end
41
+
42
+ def raise_on_failure(response)
43
+ if response.success?
44
+ response
45
+ else
46
+ raise ErrorFactory.create(response)
47
+ end
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,17 @@
1
+ module Notion
2
+ class Blocks
3
+ def children
4
+ Children.new
5
+ end
6
+ end
7
+
8
+ class Children
9
+ def list(block_id, query: {})
10
+ RequestClient.active_client.get("/v1/blocks/#{block_id}/children", query: query)
11
+ end
12
+
13
+ def append(block_id, body)
14
+ RequestClient.active_client.patch("/v1/blocks/#{block_id}/children", body: body.to_json)
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,19 @@
1
+ module Notion
2
+ class Databases
3
+ def retrieve(id)
4
+ RequestClient.active_client.get("/v1/databases/#{id}")
5
+ end
6
+
7
+ def list
8
+ RequestClient.active_client.get("/v1/databases")
9
+ end
10
+
11
+ def query(id, body)
12
+ RequestClient.active_client.post("/v1/databases/#{id}/query", body: body.to_json)
13
+ end
14
+
15
+ def create(body)
16
+ RequestClient.active_client.post("/v1/databases", body: body.to_json)
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,15 @@
1
+ module Notion
2
+ class Pages
3
+ def retrieve(id)
4
+ RequestClient.active_client.get("/v1/pages/#{id}")
5
+ end
6
+
7
+ def create(body)
8
+ RequestClient.active_client.post("/v1/pages", body: body.to_json)
9
+ end
10
+
11
+ def update(id, body)
12
+ RequestClient.active_client.patch("/v1/pages/#{id}", body: body.to_json)
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,11 @@
1
+ module Notion
2
+ class Users
3
+ def list
4
+ RequestClient.active_client.get("/v1/users")
5
+ end
6
+
7
+ def retrieve(id)
8
+ RequestClient.active_client.get("/v1/users/#{id}")
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,3 @@
1
+ module Notion
2
+ VERSION = "0.4.0"
3
+ end
@@ -1,35 +1,37 @@
1
- require_relative "lib/notion/version"
2
-
3
- Gem::Specification.new do |spec|
4
- spec.name = "notion-sdk-ruby"
5
- spec.version = Notion::VERSION
6
- spec.authors = ["Graham Marlow"]
7
- spec.email = ["mgmarlow@hey.com"]
8
-
9
- spec.summary = "Notion SDK"
10
- spec.homepage = "https://github.com/mgmarlow/notion-sdk-ruby"
11
- spec.license = "MIT"
12
- spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
13
-
14
- spec.metadata["homepage_uri"] = spec.homepage
15
- spec.metadata["source_code_uri"] = "https://github.com/mgmarlow/notion-sdk-ruby"
16
- spec.metadata["changelog_uri"] = "https://github.com/mgmarlow/notion-sdk-ruby/blob/master/CHANGELOG.md"
17
-
18
- # Specify which files should be added to the gem when it is released.
19
- # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
20
- spec.files = Dir.chdir(File.expand_path("..", __FILE__)) do
21
- `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
22
- end
23
- spec.bindir = "exe"
24
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
25
- spec.require_paths = ["lib"]
26
-
27
- spec.add_dependency 'httparty', "~> 0.18.1"
28
-
29
- spec.add_development_dependency 'rake', "~> 12.0"
30
- spec.add_development_dependency 'rspec', "~> 3.0"
31
- spec.add_development_dependency 'standardrb', "~> 1.0"
32
- spec.add_development_dependency 'webmock', "~> 3.12"
33
- spec.add_development_dependency 'pry', "~> 0.14.1"
34
- spec.add_development_dependency 'dotenv', "~> 2.7"
35
- end
1
+ lib = File.expand_path("../lib", __FILE__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require_relative "lib/notion-sdk-ruby/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "notion-sdk-ruby"
7
+ spec.version = Notion::VERSION
8
+ spec.authors = ["Graham Marlow"]
9
+ spec.email = ["mgmarlow@hey.com"]
10
+
11
+ spec.summary = "Notion SDK"
12
+ spec.homepage = "https://github.com/mgmarlow/notion-sdk-ruby"
13
+ spec.license = "MIT"
14
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
15
+
16
+ spec.metadata["homepage_uri"] = spec.homepage
17
+ spec.metadata["source_code_uri"] = "https://github.com/mgmarlow/notion-sdk-ruby"
18
+ spec.metadata["changelog_uri"] = "https://github.com/mgmarlow/notion-sdk-ruby/blob/master/CHANGELOG.md"
19
+
20
+ # Specify which files should be added to the gem when it is released.
21
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
22
+ spec.files = Dir.chdir(File.expand_path("..", __FILE__)) do
23
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
24
+ end
25
+ spec.bindir = "exe"
26
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
27
+ spec.require_paths = ["lib"]
28
+
29
+ spec.add_dependency "httparty", "~> 0.18.1"
30
+
31
+ spec.add_development_dependency "rake", "~> 12.0"
32
+ spec.add_development_dependency "rspec", "~> 3.0"
33
+ spec.add_development_dependency "standardrb", "~> 1.0"
34
+ spec.add_development_dependency "webmock", "~> 3.12"
35
+ spec.add_development_dependency "pry", "~> 0.14.1"
36
+ spec.add_development_dependency "dotenv", "~> 2.7"
37
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: notion-sdk-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Graham Marlow
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-05-17 00:00:00.000000000 Z
11
+ date: 2021-07-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -108,14 +108,14 @@ dependencies:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
110
  version: '2.7'
111
- description:
111
+ description:
112
112
  email:
113
113
  - mgmarlow@hey.com
114
114
  executables: []
115
115
  extensions: []
116
116
  extra_rdoc_files: []
117
117
  files:
118
- - ".github/workflows/ruby.yml"
118
+ - ".github/workflows/ci.yml"
119
119
  - ".gitignore"
120
120
  - ".rspec"
121
121
  - ".travis.yml"
@@ -127,15 +127,17 @@ files:
127
127
  - Rakefile
128
128
  - bin/console
129
129
  - bin/setup
130
- - lib/notion.rb
131
- - lib/notion/client.rb
132
- - lib/notion/endpoints.rb
133
- - lib/notion/endpoints/blocks.rb
134
- - lib/notion/endpoints/databases.rb
135
- - lib/notion/endpoints/pages.rb
136
- - lib/notion/endpoints/search.rb
137
- - lib/notion/endpoints/users.rb
138
- - lib/notion/version.rb
130
+ - lib/notion-sdk-ruby.rb
131
+ - lib/notion-sdk-ruby/client.rb
132
+ - lib/notion-sdk-ruby/config.rb
133
+ - lib/notion-sdk-ruby/error.rb
134
+ - lib/notion-sdk-ruby/operations/search.rb
135
+ - lib/notion-sdk-ruby/request_client.rb
136
+ - lib/notion-sdk-ruby/resources/blocks.rb
137
+ - lib/notion-sdk-ruby/resources/databases.rb
138
+ - lib/notion-sdk-ruby/resources/pages.rb
139
+ - lib/notion-sdk-ruby/resources/users.rb
140
+ - lib/notion-sdk-ruby/version.rb
139
141
  - notion-sdk-ruby.gemspec
140
142
  homepage: https://github.com/mgmarlow/notion-sdk-ruby
141
143
  licenses:
@@ -144,7 +146,7 @@ metadata:
144
146
  homepage_uri: https://github.com/mgmarlow/notion-sdk-ruby
145
147
  source_code_uri: https://github.com/mgmarlow/notion-sdk-ruby
146
148
  changelog_uri: https://github.com/mgmarlow/notion-sdk-ruby/blob/master/CHANGELOG.md
147
- post_install_message:
149
+ post_install_message:
148
150
  rdoc_options: []
149
151
  require_paths:
150
152
  - lib
@@ -159,8 +161,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
159
161
  - !ruby/object:Gem::Version
160
162
  version: '0'
161
163
  requirements: []
162
- rubygems_version: 3.0.3
163
- signing_key:
164
+ rubygems_version: 3.2.3
165
+ signing_key:
164
166
  specification_version: 4
165
167
  summary: Notion SDK
166
168
  test_files: []
@@ -1,35 +0,0 @@
1
- # This workflow uses actions that are not certified by GitHub.
2
- # They are provided by a third-party and are governed by
3
- # separate terms of service, privacy policy, and support
4
- # documentation.
5
- # This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
6
- # For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
7
-
8
- name: Ruby
9
-
10
- on:
11
- push:
12
- branches: [ main ]
13
- pull_request:
14
- branches: [ main ]
15
-
16
- jobs:
17
- test:
18
-
19
- runs-on: ubuntu-latest
20
- strategy:
21
- matrix:
22
- ruby-version: ['2.6', '2.7', '3.0']
23
-
24
- steps:
25
- - uses: actions/checkout@v2
26
- - name: Set up Ruby
27
- # To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
28
- # change this to (see https://github.com/ruby/setup-ruby#versioning):
29
- # uses: ruby/setup-ruby@v1
30
- uses: ruby/setup-ruby@473e4d8fe5dd94ee328fdfca9f8c9c7afc9dae5e
31
- with:
32
- ruby-version: ${{ matrix.ruby-version }}
33
- bundler-cache: true # runs 'bundle install' and caches installed gems automatically
34
- - name: Run tests
35
- run: bundle exec rake
data/lib/notion.rb DELETED
@@ -1,13 +0,0 @@
1
- require "httparty"
2
- require "notion/version"
3
- require "notion/endpoints/blocks"
4
- require "notion/endpoints/databases"
5
- require "notion/endpoints/pages"
6
- require "notion/endpoints/search"
7
- require "notion/endpoints/users"
8
- require "notion/endpoints"
9
- require "notion/client"
10
-
11
- module Notion
12
- class Error < StandardError; end
13
- end
data/lib/notion/client.rb DELETED
@@ -1,12 +0,0 @@
1
- module Notion
2
- class Client
3
- include Endpoints
4
- include HTTParty
5
- headers 'Content-Type': "application/json"
6
- base_uri "https://api.notion.com"
7
-
8
- def initialize(token:)
9
- self.class.headers({Authorization: "Bearer #{token}"})
10
- end
11
- end
12
- end
@@ -1,9 +0,0 @@
1
- module Notion
2
- module Endpoints
3
- include Databases
4
- include Pages
5
- include Blocks
6
- include Users
7
- include Search
8
- end
9
- end
@@ -1,13 +0,0 @@
1
- module Notion
2
- module Endpoints
3
- module Blocks
4
- def get_block_children(id, params: {})
5
- self.class.get("/v1/blocks/#{id}/children", query: params)
6
- end
7
-
8
- def append_block_children(id, body)
9
- self.class.patch("/v1/blocks/#{id}/children", body: body.to_json)
10
- end
11
- end
12
- end
13
- end
@@ -1,17 +0,0 @@
1
- module Notion
2
- module Endpoints
3
- module Databases
4
- def get_database(id)
5
- self.class.get("/v1/databases/#{id}")
6
- end
7
-
8
- def get_databases
9
- self.class.get("/v1/databases")
10
- end
11
-
12
- def query_database(id, body)
13
- self.class.post("/v1/databases/#{id}/query", body: body.to_json)
14
- end
15
- end
16
- end
17
- end
@@ -1,17 +0,0 @@
1
- module Notion
2
- module Endpoints
3
- module Pages
4
- def get_page(id)
5
- self.class.get("/v1/pages/#{id}")
6
- end
7
-
8
- def create_page(body)
9
- self.class.post("/v1/pages", body: body.to_json)
10
- end
11
-
12
- def update_page(id, body)
13
- self.class.patch("/v1/pages/#{id}", body: body.to_json)
14
- end
15
- end
16
- end
17
- end
@@ -1,9 +0,0 @@
1
- module Notion
2
- module Endpoints
3
- module Search
4
- def search(body)
5
- self.class.post("/v1/search", body: body.to_json)
6
- end
7
- end
8
- end
9
- end
@@ -1,13 +0,0 @@
1
- module Notion
2
- module Endpoints
3
- module Users
4
- def get_users
5
- self.class.get("/v1/users")
6
- end
7
-
8
- def get_user(id)
9
- self.class.get("/v1/users/#{id}")
10
- end
11
- end
12
- end
13
- end
@@ -1,3 +0,0 @@
1
- module Notion
2
- VERSION = "0.2.2"
3
- end