sunil 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.github/workflows/gem-push.yml +33 -0
- data/.gitignore +12 -0
- data/.talismanrc +1 -0
- data/.yardopts +6 -0
- data/CHANGELOG.md +79 -0
- data/CODEOWNERS +1 -0
- data/CODE_OF_CONDUCT.md +73 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +77 -0
- data/LICENSE.txt +21 -0
- data/README.md +197 -0
- data/SECURITY.md +27 -0
- data/lib/contentstack/api.rb +191 -0
- data/lib/contentstack/asset.rb +69 -0
- data/lib/contentstack/asset_collection.rb +28 -0
- data/lib/contentstack/client.rb +92 -0
- data/lib/contentstack/content_type.rb +54 -0
- data/lib/contentstack/entry.rb +222 -0
- data/lib/contentstack/entry_collection.rb +45 -0
- data/lib/contentstack/error.rb +7 -0
- data/lib/contentstack/query.rb +654 -0
- data/lib/contentstack/region.rb +6 -0
- data/lib/contentstack/sync_result.rb +30 -0
- data/lib/contentstack/version.rb +3 -0
- data/lib/contentstack.rb +32 -0
- data/lib/util.rb +111 -0
- data/rakefile.rb +4 -0
- data/spec/asset_collection_spec.rb +16 -0
- data/spec/asset_spec.rb +48 -0
- data/spec/content_type_spec.rb +81 -0
- data/spec/contentstack_spec.rb +39 -0
- data/spec/entry_collection_spec.rb +42 -0
- data/spec/entry_spec.rb +102 -0
- data/spec/fixtures/asset.json +1 -0
- data/spec/fixtures/asset_collection.json +1 -0
- data/spec/fixtures/category_content_type.json +1 -0
- data/spec/fixtures/category_entry.json +1 -0
- data/spec/fixtures/category_entry_collection.json +1 -0
- data/spec/fixtures/category_entry_collection_without_count.json +1 -0
- data/spec/fixtures/content_types.json +1 -0
- data/spec/fixtures/product_entry.json +1 -0
- data/spec/fixtures/product_entry_collection.json +1 -0
- data/spec/fixtures/sync_init.json +2975 -0
- data/spec/query_spec.rb +206 -0
- data/spec/spec_helper.rb +181 -0
- data/spec/sync_spec.rb +27 -0
- data/sunil.gemspec +30 -0
- metadata +186 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: a87df1ce834580457bbeea0065eef103b069e19ec81b6d91b7099875eaa4aa36
|
4
|
+
data.tar.gz: 3564b0f0cc6d65ecd85bd8d40dd7dc33c2b83d2b6c8232d6e0e353ae8ae836db
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: f3a22fb224fb6cf6fa1fcd9fdf573bd98f6680f148aa4f800dd45efb6f78438adf858a35c6f280e328113d02e67047c0d4fd7cd2d61ce50bf15e0ab505c0c749
|
7
|
+
data.tar.gz: a2d21d1325c40164eaebdc8aa68e8d686522ce8f8675cad006118b87db4441430032bd05596860d3b38627785121476d402aad9081a36e648b9af446dfb33fe9
|
@@ -0,0 +1,33 @@
|
|
1
|
+
name: Ruby Gem
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches: [ "master" ]
|
6
|
+
pull_request:
|
7
|
+
branches: [ "master" ]
|
8
|
+
|
9
|
+
jobs:
|
10
|
+
build:
|
11
|
+
name: Build + Publish
|
12
|
+
runs-on: ubuntu-latest
|
13
|
+
permissions:
|
14
|
+
contents: read
|
15
|
+
packages: write
|
16
|
+
|
17
|
+
steps:
|
18
|
+
- uses: actions/checkout@v3
|
19
|
+
- name: Set up Ruby 2.6
|
20
|
+
uses: actions/setup-ruby@v1
|
21
|
+
with:
|
22
|
+
ruby-version: 2.6.x
|
23
|
+
|
24
|
+
- name: Publish to RubyGems
|
25
|
+
run: |
|
26
|
+
mkdir -p $HOME/.gem
|
27
|
+
touch $HOME/.gem/credentials
|
28
|
+
chmod 0600 $HOME/.gem/credentials
|
29
|
+
printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
|
30
|
+
gem build *.gemspec
|
31
|
+
gem push *.gem
|
32
|
+
env:
|
33
|
+
GEM_HOST_API_KEY: "${{secrets.RUBYGEMS_AUTH_TOKEN}}"
|
data/.gitignore
ADDED
data/.talismanrc
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
threshold: medium
|
data/.yardopts
ADDED
data/CHANGELOG.md
ADDED
@@ -0,0 +1,79 @@
|
|
1
|
+
## CHANGELOG
|
2
|
+
------------------------------------------------
|
3
|
+
## Version 0.4.3
|
4
|
+
### Date: 17th-Sept-2021
|
5
|
+
### Dependency update
|
6
|
+
- Issue for Monkey patching resolved. Implemented Refine to extend class within module scope.
|
7
|
+
|
8
|
+
------------------------------------------------
|
9
|
+
## Version 0.4.2
|
10
|
+
### Date: 2nd-Sept-2021
|
11
|
+
### Dependency update
|
12
|
+
- Added URI open on open uri deprecation
|
13
|
+
|
14
|
+
------------------------------------------------
|
15
|
+
## Version 0.4.1
|
16
|
+
### Date: 2nd-Jun-2021
|
17
|
+
### Dependency update
|
18
|
+
- Updated gemspec dependency
|
19
|
+
|
20
|
+
------------------------------------------------
|
21
|
+
|
22
|
+
## Version 0.4.0
|
23
|
+
### Date: 16th-Apr-2021
|
24
|
+
### New Features
|
25
|
+
- Embedded feature Support added
|
26
|
+
|
27
|
+
------------------------------------------------
|
28
|
+
|
29
|
+
## Version 0.3.0
|
30
|
+
### Date: 17th-Mar-2021
|
31
|
+
### New Features
|
32
|
+
- Sync API module support added
|
33
|
+
|
34
|
+
------------------------------------------------
|
35
|
+
## Version 0.2.0
|
36
|
+
|
37
|
+
### New Features
|
38
|
+
- Entry
|
39
|
+
- locale - function for passing locale is added
|
40
|
+
- only - function for getting only specified field
|
41
|
+
- except - function for getting field except specified field
|
42
|
+
- include_reference - function for including reference in entry
|
43
|
+
- include_schema - function for including schema along with entry added
|
44
|
+
- include_content_type - function for including content type details along with entry added
|
45
|
+
- include_owner - function for getting owner of entry
|
46
|
+
- include_fallback - function for getting published fallback locale content, if specified locale content is not published
|
47
|
+
|
48
|
+
- Query
|
49
|
+
- include_fallback - function for getting published fallback locale content, if specified locale content is not published
|
50
|
+
|
51
|
+
|
52
|
+
------------------------------------------------
|
53
|
+
|
54
|
+
## Version 0.1.0
|
55
|
+
|
56
|
+
### Bug
|
57
|
+
- Stack Tokens Moved to Headers
|
58
|
+
|
59
|
+
------------------------------------------------
|
60
|
+
|
61
|
+
## Version 0.0.4
|
62
|
+
|
63
|
+
### Enhancement
|
64
|
+
- Region support added
|
65
|
+
|
66
|
+
------------------------------------------------
|
67
|
+
|
68
|
+
## Version 0.0.3
|
69
|
+
|
70
|
+
### Enhancement
|
71
|
+
- Query - function for passing locale is added.
|
72
|
+
|
73
|
+
------------------------------------------------
|
74
|
+
|
75
|
+
## Version 0.0.1
|
76
|
+
|
77
|
+
- Initial release
|
78
|
+
|
79
|
+
------------------------------------------------
|
data/CODEOWNERS
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
* @contentstack/security-admin @contentstack/sdk-admin
|
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,73 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or advances
|
26
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
27
|
+
* Public or private harassment
|
28
|
+
* Publishing others' private information, such as a physical or electronic
|
29
|
+
address, without explicit permission
|
30
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
31
|
+
professional setting
|
32
|
+
|
33
|
+
## Our Responsibilities
|
34
|
+
|
35
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
36
|
+
behavior and are expected to take appropriate and fair corrective action in
|
37
|
+
response to any instances of unacceptable behavior.
|
38
|
+
|
39
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
40
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
41
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
42
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
43
|
+
threatening, offensive, or harmful.
|
44
|
+
|
45
|
+
## Scope
|
46
|
+
|
47
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
48
|
+
when an individual is representing the project or its community. Examples of
|
49
|
+
representing a project or community include using an official project e-mail
|
50
|
+
address, posting via an official social media account, or acting as an appointed
|
51
|
+
representative at an online or offline event. Representation of a project may be
|
52
|
+
further defined and clarified by project maintainers.
|
53
|
+
|
54
|
+
## Enforcement
|
55
|
+
|
56
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
57
|
+
reported by contacting the project team at amit.erandole@gmail.com. All
|
58
|
+
complaints will be reviewed and investigated and will result in a response that
|
59
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
60
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
61
|
+
Further details of specific enforcement policies may be posted separately.
|
62
|
+
|
63
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
64
|
+
faith may face temporary or permanent repercussions as determined by other
|
65
|
+
members of the project's leadership.
|
66
|
+
|
67
|
+
## Attribution
|
68
|
+
|
69
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
70
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
71
|
+
|
72
|
+
[homepage]: http://contributor-covenant.org
|
73
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,77 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
contentstack (0.5.0)
|
5
|
+
activesupport (>= 3.2, < 6.2)
|
6
|
+
contentstack_utils (~> 1.0, >= 1.0.1)
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: https://rubygems.org/
|
10
|
+
specs:
|
11
|
+
activesupport (6.1.5)
|
12
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
13
|
+
i18n (>= 1.6, < 2)
|
14
|
+
minitest (>= 5.1)
|
15
|
+
tzinfo (~> 2.0)
|
16
|
+
zeitwerk (~> 2.3)
|
17
|
+
addressable (2.8.0)
|
18
|
+
public_suffix (>= 2.0.2, < 5.0)
|
19
|
+
concurrent-ruby (1.1.10)
|
20
|
+
contentstack_utils (1.1.0)
|
21
|
+
activesupport (>= 3.2, < 6.2)
|
22
|
+
nokogiri (~> 1.11, >= 1.11.0)
|
23
|
+
crack (0.4.5)
|
24
|
+
rexml
|
25
|
+
diff-lcs (1.4.4)
|
26
|
+
docile (1.4.0)
|
27
|
+
hashdiff (1.0.1)
|
28
|
+
i18n (1.10.0)
|
29
|
+
concurrent-ruby (~> 1.0)
|
30
|
+
mini_portile2 (2.8.0)
|
31
|
+
minitest (5.15.0)
|
32
|
+
nokogiri (1.13.4)
|
33
|
+
mini_portile2 (~> 2.8.0)
|
34
|
+
racc (~> 1.4)
|
35
|
+
public_suffix (4.0.6)
|
36
|
+
racc (1.6.0)
|
37
|
+
rexml (3.2.5)
|
38
|
+
rspec (3.10.0)
|
39
|
+
rspec-core (~> 3.10.0)
|
40
|
+
rspec-expectations (~> 3.10.0)
|
41
|
+
rspec-mocks (~> 3.10.0)
|
42
|
+
rspec-core (3.10.1)
|
43
|
+
rspec-support (~> 3.10.0)
|
44
|
+
rspec-expectations (3.10.1)
|
45
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
46
|
+
rspec-support (~> 3.10.0)
|
47
|
+
rspec-mocks (3.10.2)
|
48
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
49
|
+
rspec-support (~> 3.10.0)
|
50
|
+
rspec-support (3.10.2)
|
51
|
+
simplecov (0.21.2)
|
52
|
+
docile (~> 1.1)
|
53
|
+
simplecov-html (~> 0.11)
|
54
|
+
simplecov_json_formatter (~> 0.1)
|
55
|
+
simplecov-html (0.12.3)
|
56
|
+
simplecov_json_formatter (0.1.3)
|
57
|
+
tzinfo (2.0.4)
|
58
|
+
concurrent-ruby (~> 1.0)
|
59
|
+
webmock (3.11.3)
|
60
|
+
addressable (>= 2.3.6)
|
61
|
+
crack (>= 0.3.2)
|
62
|
+
hashdiff (>= 0.4.0, < 2.0.0)
|
63
|
+
yard (0.9.26)
|
64
|
+
zeitwerk (2.5.4)
|
65
|
+
|
66
|
+
PLATFORMS
|
67
|
+
ruby
|
68
|
+
|
69
|
+
DEPENDENCIES
|
70
|
+
contentstack!
|
71
|
+
rspec (~> 3.10.0)
|
72
|
+
simplecov (~> 0.21.1)
|
73
|
+
webmock (~> 3.11.0)
|
74
|
+
yard (~> 0.9.26)
|
75
|
+
|
76
|
+
BUNDLED WITH
|
77
|
+
2.2.7
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2012-2022 Contentstack. All Rights Reserved
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,197 @@
|
|
1
|
+
# **Ruby SDK for Contentstack**
|
2
|
+
|
3
|
+
Contentstack is a headless CMS with an API-first approach. It is a CMS that developers can use to build powerful cross-platform applications in their favorite languages. Build your application frontend, and Contentstack will take care of the rest. [Read More](https://www.contentstack.com/).
|
4
|
+
|
5
|
+
Contentstack provides Ruby SDK to build application on top of Ruby on Rails. Given below is the detailed guide and helpful resources to get started with our Ruby SDK.
|
6
|
+
|
7
|
+
## **Prerequisite**
|
8
|
+
|
9
|
+
You need ruby v2.0 or later installed to use the Contentstack Ruby SDK.
|
10
|
+
|
11
|
+
## **Setup and Installation**
|
12
|
+
|
13
|
+
Add the following code to your application's Gemfile and bundle:
|
14
|
+
|
15
|
+
gem 'contentstack'
|
16
|
+
|
17
|
+
Or you can run this command in your terminal (you might need administrator privileges to perform this installation):
|
18
|
+
|
19
|
+
gem install contentstack
|
20
|
+
|
21
|
+
To start using the SDK in your application, you will need to initialize the stack by providing the values for the keys given in the code snippet below.
|
22
|
+
```ruby
|
23
|
+
# with default region
|
24
|
+
client = Contentstack::Client.new("api_key", "delivery_token", "enviroment_name")
|
25
|
+
|
26
|
+
# with specific region
|
27
|
+
client = Contentstack::Client.new("api_key", "delivery_token", "enviroment_name",{"region": Contentstack::Region::EU})
|
28
|
+
|
29
|
+
# with custom host
|
30
|
+
client = Contentstack::Client.new("api_key", "delivery_token", "enviroment_name",{"host": "https://custom-cdn.contentstack.com"})
|
31
|
+
```
|
32
|
+
|
33
|
+
## **Key Concepts for using Contentstack**
|
34
|
+
|
35
|
+
### **Stack**
|
36
|
+
|
37
|
+
A stack is like a container that holds the content of your app. Learn more about [stacks](https://www.contentstack.com/docs/guide/stack).
|
38
|
+
|
39
|
+
### **Content Type**
|
40
|
+
|
41
|
+
Content type lets you define the structure or blueprint of a page or a section of your digital property. It is a form-like page that gives Content Managers an interface to input and upload content. [Read more](https://www.contentstack.com/docs/guide/content-types).
|
42
|
+
|
43
|
+
### **Entry**
|
44
|
+
|
45
|
+
An entry is the actual piece of content created using one of the defined content types. Learn more about [Entries](https://www.contentstack.com/docs/guide/content-management#working-with-entries).
|
46
|
+
|
47
|
+
### **Asset**
|
48
|
+
|
49
|
+
Assets refer to all the media files (images, videos, PDFs, audio files, and so on) uploaded to Contentstack. These files can be used in multiple entries. Read more about [Assets](https://www.contentstack.com/docs/guide/content-management#working-with-assets).
|
50
|
+
|
51
|
+
### **Environment**
|
52
|
+
|
53
|
+
A publishing environment corresponds to one or more deployment servers or a content delivery destination where the entries need to be published. Learn how to work with [Environments](https://www.contentstack.com/docs/guide/environments).
|
54
|
+
|
55
|
+
## **Contentstack Ruby SDK: 5-minute Quickstart**
|
56
|
+
|
57
|
+
### **Initializing your SDK**
|
58
|
+
|
59
|
+
To initialize the SDK, you need to provide values for the keys given in the snippet below:
|
60
|
+
```ruby
|
61
|
+
@stack = Contentstack::Client.new("api_key", "delivery_token", "enviroment_name")
|
62
|
+
```
|
63
|
+
|
64
|
+
To get the API credentials mentioned above, log in to your Contentstack account and then in your top panel navigation, go to Settings > Stack to view the API Key and Access Token.
|
65
|
+
|
66
|
+
### **Querying content from your stack**
|
67
|
+
|
68
|
+
To fetch all entries of of a content type, use the query given below:
|
69
|
+
```ruby
|
70
|
+
@entry = stack.content_type(<<CONTENT_TYPE_UID>>).query();
|
71
|
+
```
|
72
|
+
|
73
|
+
To fetch a specific entry from a content type, use the following query:
|
74
|
+
```ruby
|
75
|
+
@entry = stack.content_type(<<CONTENT_TYPE_UID>>).entry(<<ENTRY_UID>>);
|
76
|
+
```
|
77
|
+
|
78
|
+
### Get Multiple Entries
|
79
|
+
To retrieve multiple entries of a content type, specify the content type UID. You can also specify search parameters to filter results:
|
80
|
+
```ruby
|
81
|
+
@query = @stack.content_type('blog').query
|
82
|
+
@entries = @query.where('title', 'welcome')
|
83
|
+
.include_schema
|
84
|
+
.include_count
|
85
|
+
.fetch
|
86
|
+
puts "Total Entries -- #{@entries.count}"
|
87
|
+
@entries.each{|entry| puts "#{entry.get('title')}" }
|
88
|
+
```
|
89
|
+
|
90
|
+
To retrieve localized versions of entries, you can use the query attribute:
|
91
|
+
```ruby
|
92
|
+
entry = @stack.content_type('content_type_uid').query.locale('locale_code').fetch()
|
93
|
+
```
|
94
|
+
> Note: Currently, the above query works in case of retrieving localized versions of multiple entries only.
|
95
|
+
|
96
|
+
## **Advanced Queries**
|
97
|
+
|
98
|
+
You can query for content types, entries, assets and more using our Ruby API Reference.
|
99
|
+
|
100
|
+
[Ruby API Reference Doc](http://www.rubydoc.info/gems/contentstack)
|
101
|
+
|
102
|
+
### Paginating Responses
|
103
|
+
In a single instance, the [Get Multiple Entries](https://www.contentstack.com/docs/developers/ruby/get-started-with-ruby-sdk/#get-multiple-entries) query will retrieve only the first 100 items of the specified content type. You can paginate and retrieve the rest of the items in batches using the [skip](https://www.rubydoc.info/gems/contentstack/Contentstack/Query#skip-instance_method) and [limit](https://www.rubydoc.info/gems/contentstack/Contentstack/Query#limit-instance_method) parameters in subsequent requests.
|
104
|
+
|
105
|
+
```ruby
|
106
|
+
@stack = Contentstack::Client.new("api_key", "delivery_token", "environment")
|
107
|
+
@entries = @stack.content_type('category').query
|
108
|
+
.limit(20)
|
109
|
+
.skip(50)
|
110
|
+
.fetch
|
111
|
+
```
|
112
|
+
|
113
|
+
> Note: Currently, the Ruby SDK does not support multiple content types referencing in a single query. For more information on how to query entries and assets, refer the Queries section of our Content Delivery API documentation.
|
114
|
+
|
115
|
+
## **Working with Images**
|
116
|
+
|
117
|
+
We have introduced Image Delivery APIs that let you retrieve images and then manipulate and optimize them for your digital properties. It lets you perform a host of other actions such as crop, trim, resize, rotate, overlay, and so on.
|
118
|
+
|
119
|
+
For example, if you want to crop an image (with width as 300 and height as 400), you simply need to append query parameters at the end of the image URL, such as, https://images.contentstack.io/v3/download?crop=300,400. There are several more parameters that you can use for your images.
|
120
|
+
|
121
|
+
[Read Image Delivery API documentation](https://www.contentstack.com/docs/apis/image-delivery-api/).
|
122
|
+
|
123
|
+
|
124
|
+
## **Using the Sync API with Ruby SDK**
|
125
|
+
|
126
|
+
The Sync API takes care of syncing your Contentstack data with your app and ensures that the data is always up-to-date by providing delta updates. Contentstack’s Ruby SDK supports Sync API, which you can use to build powerful apps. Read through to understand how to use the Sync API with Contentstack Ruby SDK.
|
127
|
+
[Read Sync API documentation](https://www.contentstack.com/docs/platforms/ruby#using-the-sync-api-with-ruby-sdk).
|
128
|
+
|
129
|
+
### Initial sync
|
130
|
+
|
131
|
+
The Initial Sync process performs a complete sync of your app data. It returns all the published entries and assets of the specified stack in response.
|
132
|
+
|
133
|
+
To start the Initial Sync process, use the syncStack method.
|
134
|
+
|
135
|
+
```ruby
|
136
|
+
@sync_result = @stack.sync({init: true})
|
137
|
+
# @sync_result.items: contains sync data
|
138
|
+
# @sync_result.pagination_token: for fetching the next batch of entries using pagination token
|
139
|
+
# @sync_result.sync_token: for performing subsequent sync after initial sync
|
140
|
+
```
|
141
|
+
|
142
|
+
The response also contains a sync token, which you need to store, since this token is used to get subsequent delta updates later, as shown in the Subsequent Sync section below.
|
143
|
+
|
144
|
+
You can also fetch custom results in initial sync by using advanced sync queries.
|
145
|
+
|
146
|
+
### Sync pagination
|
147
|
+
|
148
|
+
If the result of the initial sync (or subsequent sync) contains more than 100 records, the response would be paginated. It provides pagination token in the response. You will need to use this token to get the next batch of data.
|
149
|
+
|
150
|
+
```ruby
|
151
|
+
@sync_result = @stack.sync({pagination_token : "<pagination_token>"})
|
152
|
+
# @sync_result.items: contains sync data
|
153
|
+
# @sync_result.pagination_token: For fetching the next batch of entries using pagination token
|
154
|
+
# @sync_result.sync_token: For performing subsequent sync after initial sync
|
155
|
+
```
|
156
|
+
|
157
|
+
### Subsequent sync
|
158
|
+
|
159
|
+
You can use the sync token (that you receive after initial sync) to get the updated content next time. The sync token fetches only the content that was added after your last sync, and the details of the content that was deleted or updated.
|
160
|
+
|
161
|
+
```ruby
|
162
|
+
@sync_result = @stack.sync({sync_token : "<sync_token>"})
|
163
|
+
# @sync_result.items: contains sync data
|
164
|
+
# @sync_result.pagination_token: For fetching the next batch of entries using pagination token
|
165
|
+
# @sync_result.sync_token: For performing subsequent sync after initial sync
|
166
|
+
```
|
167
|
+
|
168
|
+
### Advanced sync queries
|
169
|
+
|
170
|
+
You can use advanced sync queries to fetch custom results while performing initial sync.
|
171
|
+
[Read advanced sync queries documentation](https://www.contentstack.com/docs/guide/synchronization/using-the-sync-api-with-ruby-sdk#advanced-sync-queries)
|
172
|
+
|
173
|
+
|
174
|
+
```ruby
|
175
|
+
@sync_result = @stack.sync({init : true, locale: "<locale>" content_type_uid: "<content_type_uid>"})
|
176
|
+
# @sync_result.items: contains sync data
|
177
|
+
# @sync_result.pagination_token: For fetching the next batch of entries using pagination token
|
178
|
+
# @sync_result.sync_token: For performing subsequent sync after initial sync
|
179
|
+
```
|
180
|
+
## **Helpful Links**
|
181
|
+
|
182
|
+
* [Contentstack Website](https://www.contentstack.com)
|
183
|
+
|
184
|
+
* [Official Documentation](http://contentstack.com/docs)
|
185
|
+
|
186
|
+
* [Content Delivery API Docs](https://contentstack.com/docs/apis/content-delivery-api/)
|
187
|
+
|
188
|
+
## **The MIT License (MIT)**
|
189
|
+
|
190
|
+
Copyright © 2012-2021 [Contentstack](https://www.contentstack.com). All Rights Reserved
|
191
|
+
|
192
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
193
|
+
|
194
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
195
|
+
|
196
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
197
|
+
|
data/SECURITY.md
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
## Security
|
2
|
+
|
3
|
+
Contentstack takes the security of our software products and services seriously, which includes all source code repositories managed through our GitHub organizations.
|
4
|
+
|
5
|
+
If you believe you have found a security vulnerability in any Contentstack-owned repository, please report it to us as described below.
|
6
|
+
|
7
|
+
## Reporting Security Issues
|
8
|
+
|
9
|
+
**Please do not report security vulnerabilities through public GitHub issues.**
|
10
|
+
|
11
|
+
Send email to [security@contentstack.com](mailto:security@contentstack.com).
|
12
|
+
|
13
|
+
You should receive a response within 24 hours. If for some reason you do not, please follow up via email to ensure we received your original message.
|
14
|
+
|
15
|
+
Please include the requested information listed below (as much as you can provide) to help us better understand the nature and scope of the possible issue:
|
16
|
+
|
17
|
+
* Type of issue (e.g. buffer overflow, SQL injection, cross-site scripting, etc.)
|
18
|
+
* Full paths of source file(s) related to the manifestation of the issue
|
19
|
+
* The location of the affected source code (tag/branch/commit or direct URL)
|
20
|
+
* Any special configuration required to reproduce the issue
|
21
|
+
* Step-by-step instructions to reproduce the issue
|
22
|
+
* Proof-of-concept or exploit code (if possible)
|
23
|
+
* Impact of the issue, including how an attacker might exploit the issue
|
24
|
+
|
25
|
+
This information will help us triage your report more quickly.
|
26
|
+
|
27
|
+
[https://www.contentstack.com/trust/](https://www.contentstack.com/trust/)
|