Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,25 @@
## CHANGELOG
------------------------------------------------

## Version 0.2.0

### New Features
- Entry
- locale - function for passing locale is added
- only - function for getting only specified field
- except - function for getting field except specified field
- include_reference - function for including reference in entry
- include_schema - function for including schema along with entry added
- include_content_type - function for including content type details along with entry added
- include_owner - function for getting owner of entry
- include_fallback - function for getting published fallback locale content, if specified locale content is not published

- Query
- include_fallback - function for getting published fallback locale content, if specified locale content is not published


------------------------------------------------

## Version 0.1.0

### Bug
Expand Down
3 changes: 1 addition & 2 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ include:

Examples of unacceptable behavior by participants include:

* The use of sexualized language or imagery and unwelcome sexual attention or
advances
* The use of sexualized language or imagery and unwelcome sexual attention or advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic
Expand Down
3 changes: 2 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ source "https://rubygems.org"
gem "rspec"
gem "webmock"
gem "simplecov"
gem "activesupport"
gem "activesupport"
gem "yard"
2 changes: 2 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ GEM
addressable (>= 2.3.6)
crack (>= 0.3.2)
hashdiff (>= 0.4.0, < 2.0.0)
yard (0.9.25)
zeitwerk (2.3.0)

PLATFORMS
Expand All @@ -54,6 +55,7 @@ DEPENDENCIES
rspec
simplecov
webmock
yard

BUNDLED WITH
2.1.4
41 changes: 32 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

# **Ruby SDK for Contentstack**

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/).
Expand All @@ -22,16 +21,13 @@ Or you can run this command in your terminal (you might need administrator privi
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.

# with default region
client = Contentstack::Client.new("site_api_key", "delivery_token", "enviroment_name")
client = Contentstack::Client.new("api_key", "delivery_token", "enviroment_name")

# with specific region
client = Contentstack::Client.new("site_api_key", "delivery_token", "enviroment_name",{"region": Contentstack::Region::EU})
client = Contentstack::Client.new("api_key", "delivery_token", "enviroment_name",{"region": Contentstack::Region::EU})

# with custom host
client = Contentstack::Client.new("site_api_key", "delivery_token", "enviroment_name",{"host": "https://custom-cdn.contentstack.com"})



client = Contentstack::Client.new("api_key", "delivery_token", "enviroment_name",{"host": "https://custom-cdn.contentstack.com"})

## **Key Concepts for using Contentstack**

Expand All @@ -57,11 +53,11 @@ A publishing environment corresponds to one or more deployment servers or a cont

## **Contentstack Ruby SDK: 5-minute Quickstart**

### **Initializing your SDK **
### **Initializing your SDK**

To initialize the SDK, you need to provide values for the keys given in the snippet below:

stack = Contentstack::Client.new("site_api_key", "delivery_token", "enviroment_name")
stack = Contentstack::Client.new("api_key", "delivery_token", "enviroment_name")

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.

Expand All @@ -75,12 +71,39 @@ To fetch a specific entry from a content type, use the following query:

entry = stack.content_type(<<CONTENT_TYPE_UID>>).entry(<<ENTRY_UID>>);

### Get Multiple Entries
To retrieve multiple entries of a content type, specify the content type UID. You can also specify search parameters to filter results:

@query = @stack.content_type('blog').query
@entries = @query.where('title', 'welcome')
.include_schema
.include_count
.fetch
puts "Total Entries -- #{@entries.count}"
@entries.each{|entry| puts "#{entry.get('title')}" }
To retrieve localized versions of entries, you can use the query attribute:

entry = @stack.content_type('content_type_uid').query.locale('locale_code').fetch()

> Note: Currently, the above query works in case of retrieving localized versions of multiple entries only.

## **Advanced Queries**

You can query for content types, entries, assets and more using our Ruby API Reference.

[Ruby API Reference Doc](http://www.rubydoc.info/gems/contentstack)

### Paginating Responses
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.

@stack = Contentstack::Client.new("api_key", "delivery_token", "environment")
@entries = @stack.content_type('category').query
.limit(20)
.skip(50)
.fetch

> 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.

## **Working with Images**

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.
Expand Down
2 changes: 1 addition & 1 deletion coverage/.last_run.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"result": {
"covered_percent": 96.65
"covered_percent": 97.5
}
}
Loading