Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds the Preview API #31

Merged
merged 3 commits into from
Jun 12, 2020
Merged

Conversation

floriank
Copy link
Collaborator

@floriank floriank commented May 8, 2020

Adds the Preview API by using Contentful.Preview as a namespace for holding the same structures as Contentful.Delivery

This is also meant for refactoring out the Request code from the modules, as @asaaki suggested in #18.

It's a WIP for the moment, as I have to move a bunch of code. The generic idea is as follows:

import Contentful.Query
alias Contentful.{Delivery, Preview}

# fetches entries from the CDA
Delivery.Entries |> fetch_all 

# fetches entries from the CPA
Preview.Entries |> fetch_all

Edit: Scratch that, it's easier to just follow the idea from @zaeemarshad in #9.

# configure the preview API
# in your config.exs
config :contentful, delivery: [
    endpoint: :preview,
    space_id: "<my_space_id>",
    environment: "<my_environment>",
    access_token: "<my_access_token_cpa>"
]
# then, in your code:
import Contentful.Query
alias Contentful.Delivery, as: Preview
{:ok, entry} = Preview.Entries |> fetch_one("my_entry_id")

This also closes #9 if successful.

@floriank floriank self-assigned this May 8, 2020
@coveralls
Copy link

Pull Request Test Coverage Report for Build 859394d66e575354d39b8385f3b608a2c317efd8-PR-31

  • 0 of 29 (0.0%) changed or added relevant lines in 2 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-14.6%) to 52.985%

Changes Missing Coverage Covered Lines Changed/Added Lines %
lib/contentful_preview/entries.ex 0 1 0.0%
lib/contentful_preview/preview.ex 0 28 0.0%
Totals Coverage Status
Change from base Build c412f59c3a8d0ef250f5a39bceac3dd3682f8bd3: -14.6%
Covered Lines: 71
Relevant Lines: 134

💛 - Coveralls

@coveralls
Copy link

coveralls commented May 8, 2020

Pull Request Test Coverage Report for Build f13553ecca52a1748ea562665207c0d72df5bbb3-PR-31

  • 6 of 9 (66.67%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.7%) to 67.568%

Changes Missing Coverage Covered Lines Changed/Added Lines %
lib/contentful_delivery/delivery.ex 6 9 66.67%
Totals Coverage Status
Change from base Build fab1b3f20e9ac3a770a1d785119d3116851c0165: -0.7%
Covered Lines: 75
Relevant Lines: 111

💛 - Coveralls

@floriank floriank mentioned this pull request May 12, 2020
@floriank floriank force-pushed the adds-preview-api branch from 859394d to 138347c Compare May 17, 2020 13:08
floriank added 3 commits June 11, 2020 14:27
also adds some dummy code for entries
Basically omits a separate implementation for the CPA and just uses
a configurable endpoint.

The endpoint can take a custom url too, in case we ever need to roll out
a CDA feature complete non-CPA system.
@floriank floriank marked this pull request as ready for review June 11, 2020 12:58
@floriank floriank requested review from asaaki and dlitvakb June 11, 2020 12:58
Copy link
Collaborator

@asaaki asaaki left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting and cheap approach. Feels a bit hacky, but if it works I'm okay with it. Will probably be fine for 99% of the use cases.

@floriank floriank merged commit a6abd60 into contentful-userland:master Jun 12, 2020
@floriank floriank deleted the adds-preview-api branch June 12, 2020 09:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Hardcoded end point
3 participants