notion 1.0.2 → 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +40 -6
- data/lib/notion_api/core.rb +1 -1
- data/lib/notion_api/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 58ac8026dc81c27d34f42b51e388bd036b03d2338ef9113b43bcaee0bd57f6a2
|
4
|
+
data.tar.gz: 914d54deb74e73057b6d52f0c7a8227903b501250243f4d61d81c2196e42bc0f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bdb71d3859daaf1ded2f418cc348a9d3c3fb65cf446efd94df49dc28330355571b078415f8a48f53a31328c7f672f6e0b26f02176e8ec9702810e144c5341535
|
7
|
+
data.tar.gz: 035343a8e4fe1326b7e735d4a019db969d1c3d356faaf80f56fc861d60e9cdb3ee419fc9c776abaf7ffeaab0572a69dfec19fe42ab6362e600dd014f105c593e
|
data/README.md
CHANGED
@@ -1,5 +1,25 @@
|
|
1
|
+
|
2
|
+
|
1
3
|
# Unofficial Notion Client for Ruby.
|
2
|
-
[![
|
4
|
+
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/f13e49a8807e4fe297273f48bd8d7a61)](https://app.codacy.com/gh/danmurphy1217/notion-ruby?utm_source=github.com&utm_medium=referral&utm_content=danmurphy1217/notion-ruby&utm_campaign=Badge_Grade)
|
5
|
+
[![Build Status](https://travis-ci.com/danmurphy1217/notion-ruby.svg?branch=master)](https://travis-ci.com/danmurphy1217/notion-ruby) [![Ruby Style Guide](https://img.shields.io/badge/code_style-rubocop-brightgreen.svg)](https://github.com/rubocop-hq/rubocop) [![Gem Version](https://badge.fury.io/rb/notion.svg)](https://badge.fury.io/rb/notion)
|
6
|
+
|
7
|
+
- Read the [blog post](https://towardsdatascience.com/introducing-the-notion-api-ruby-gem-d47d4a6ef0ca), which outlines why I built this and some of the functionality.
|
8
|
+
- Check out the [Gem](https://rubygems.org/gems/notion)!
|
9
|
+
|
10
|
+
## Table of Contents
|
11
|
+
- [Getting Started](#getting-started)
|
12
|
+
* [Installation](#installation)
|
13
|
+
- [Retrieving a Page](#retrieving-a-page)
|
14
|
+
- [Retrieving a Block within the Page](#retrieving-a-block-within-the-page)
|
15
|
+
* [Get a Block](#get-a-block)
|
16
|
+
* [Get a Collection View - Table](#get-a-collection-view---table)
|
17
|
+
- [Creating New Blocks](#creating-new-blocks)
|
18
|
+
* [Create a block whose parent is the page](#create-a-block-whose-parent-is-the-page)
|
19
|
+
* [Create a block whose parent is another block](#create-a-block-whose-parent-is-another-block)
|
20
|
+
- [Creating New Collections](#creating-new-collections)
|
21
|
+
- [Troubleshooting](#troubleshooting)
|
22
|
+
* [No results returned when attempting to get a page](#no-results-returned-when-attempting-to-get-a-page)
|
3
23
|
|
4
24
|
## Getting Started
|
5
25
|
### Installation
|
@@ -9,7 +29,7 @@ gem install notion
|
|
9
29
|
```
|
10
30
|
Then, place this at the top of your file:
|
11
31
|
```ruby
|
12
|
-
require 'notion_api'
|
32
|
+
require 'notion_api'
|
13
33
|
```
|
14
34
|
To get started using the gem, you'll first need to retrieve your token_v2 credentials by signing into Notion online, navigating to the developer tools, inspecting the cookies, and finding the value associated with the **token_v2** key.
|
15
35
|
|
@@ -128,8 +148,8 @@ Here's a high-level example:
|
|
128
148
|
The block types available to the `create` method are:
|
129
149
|
1. `DividerBlock`
|
130
150
|
2. `TodoBlock`
|
131
|
-
3. `CodeBlock`
|
132
|
-
4. `HeaderBlock`
|
151
|
+
3. `CodeBlock`
|
152
|
+
4. `HeaderBlock`
|
133
153
|
5. `SubHeaderBlock`
|
134
154
|
6. `SubSubHeaderBlock`
|
135
155
|
7. `PageBlock`
|
@@ -139,8 +159,8 @@ The block types available to the `create` method are:
|
|
139
159
|
11. `QuoteBlock`
|
140
160
|
12. `CalloutBlock`
|
141
161
|
13. `LatexBlock`
|
142
|
-
14. `TextBlock`
|
143
|
-
15. `ImageBlock` and
|
162
|
+
14. `TextBlock`
|
163
|
+
15. `ImageBlock` and
|
144
164
|
16. `TableOfContentsBlock`.
|
145
165
|
If you want to create a collection, utilize the `create_collection` method [defined below].
|
146
166
|
|
@@ -247,3 +267,17 @@ The first argument passed to `create_collection` determines which type of collec
|
|
247
267
|
3. calendar
|
248
268
|
4. timeline
|
249
269
|
5. gallery
|
270
|
+
|
271
|
+
## Troubleshooting
|
272
|
+
### No results returned when attempting to get a page
|
273
|
+
If an empty hash is returned when you attempt to retrieve a Notion page, you'll need to include the `x-notion-active-user-header` when instantiating the Notion Client.
|
274
|
+
The endpoint used by this wrapper to load a page is `/loadPageChunk`, check out the request headers in your developer tools Network tab.
|
275
|
+
|
276
|
+
From here, you can instantiate the Notion Client with the following code:
|
277
|
+
```ruby
|
278
|
+
>>> @client = NotionAPI::Client.new(
|
279
|
+
"<insert_v2_token_here>",
|
280
|
+
"<insert_x_notion_active_user_header_here>"
|
281
|
+
)
|
282
|
+
```
|
283
|
+
|
data/lib/notion_api/core.rb
CHANGED
@@ -140,7 +140,7 @@ module NotionAPI
|
|
140
140
|
# ! retrieves all info pertaining to a block Id.
|
141
141
|
# ! clean_id -> the block ID or URL cleaned : ``str``
|
142
142
|
Core.options['cookies'][:token_v2] = @@token_v2
|
143
|
-
Core.options['headers']['x-notion-active-user-header'] =
|
143
|
+
Core.options['headers']['x-notion-active-user-header'] = @@active_user_header
|
144
144
|
cookies = Core.options['cookies']
|
145
145
|
headers = Core.options['headers']
|
146
146
|
|
data/lib/notion_api/version.rb
CHANGED