Skip to content

DynamoMTL/contentful.ex

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Contentful Delivery SDK

Elixir client for the Contentful Content Delivery API.

Contentful is a content management platform for web applications, mobile apps and connected devices. It allows you to create, edit & manage content in the cloud and publish it anywhere via powerful API. Contentful offers tools for managing editorial teams and enabling cooperation between organizations.

Installation

If available in Hex, the package can be installed as:

  1. Add contentful to your list of dependencies in mix.exs:

    def deps do [{:contentful, "~> 0.0.1"}] end

  2. Ensure contentful is started before your application:

    def application do [applications: [:contentful]] end

Usage

All request accept an extra parameter for request parameters.

Entries

  • All Entries:
SPACE_ID = "my_space_id"
ACCESS_TOKEN = "my_access_token"

entries = Contentful.Delivery.entries(SPACE_ID, ACCESS_TOKEN)

# Printing Content Type ID for every entry
Enum.each(entries, fn (entry) -> IO.puts(entry["sys"]["contentType]["sys"]["id"]) end)
  • Single Entry:
SPACE_ID = "my_space_id"
ACCESS_TOKEN = "my_access_token"
ENTRY_ID = "my_entry_id"

entry = Contentful.Delivery.entry(SPACE_ID, ACCESS_TOKEN, ENTRY_ID)
  • Search Parameters
SPACE_ID = "my_space_id"
ACCESS_TOKEN = "my_access_token"
SEARCH_PARAMS = %{
  "query" => "Some Fancy Text",
  "content_type" => "cat"
}

entries = Contentful.Delivery.entries(SPACE_ID, ACCESS_TOKEN, SEARCH_PARAMS)

Assets

  • All Assets:
SPACE_ID = "my_space_id"
ACCESS_TOKEN = "my_access_token"

assets = Contentful.Delivery.assets(SPACE_ID, ACCESS_TOKEN)
  • Single Asset:
SPACE_ID = "my_space_id"
ACCESS_TOKEN = "my_access_token"
ASSET_ID = "my_asset_id"

asset = Contentful.Delivery.asset(SPACE_ID, ACCESS_TOKEN, ASSET_ID)

Content Types

  • All Content Types:
SPACE_ID = "my_space_id"
ACCESS_TOKEN = "my_access_token"

content_types = Contentful.Delivery.content_types(SPACE_ID, ACCESS_TOKEN)
  • Single Content Type:
SPACE_ID = "my_space_id"
ACCESS_TOKEN = "my_access_token"
CONTENT_TYPE_ID = "my_content_type_id"

content_type = Contentful.Delivery.content_type(SPACE_ID, ACCESS_TOKEN, CONTENT_TYPE_ID)

Space

SPACE_ID = "my_space_id"
ACCESS_TOKEN = "my_access_token"

space = Contentful.Delivery.space(SPACE_ID, ACCESS_TOKEN)

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

About

Elixir SDK for the Contentful Delivery API

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Elixir 100.0%