Skip to content

Docs: Partner: First pass at documenting endpoints#8865

Merged
oskosk merged 13 commits intomasterfrom
add/jps-v2-api-direct-docs
Feb 20, 2018
Merged

Docs: Partner: First pass at documenting endpoints#8865
oskosk merged 13 commits intomasterfrom
add/jps-v2-api-direct-docs

Conversation

@ebinnion
Copy link
Copy Markdown
Contributor

@ebinnion ebinnion commented Feb 17, 2018

JPS v1 required hosting partners perform a lot of integration work setting up oAuth and then integrating in our APIs. We tried to simplify this as much as possible in JPS v2 by shipping two shell scripts that handle provisioning and cancellation of plans.

But, there are cases where a host may actually want to call the API instead of running a CLI command. For example, what if the site is already gone by the time the CLI command can be run?

It's currently pretty straightforward to cancel a plan by making calls directly to the API. A hosting partner simply needs to get an access token then call the cancellation endpoint, passing the domain and access token. That process is what is documented in this PR.

Provisioning a plan via calls directly to the API is much less straightforward. Currently, we require details such as the blog ID to be passed with the plan provisioning call, things that are better handled via the CLI.

For now, provisioning a plan is marked as TBD while we consider how to approach that.

To test:

  • Create a partner and key by following instructions here in PCYsg-emq-p2
  • Provision a plan manually via Jetpack Start and shell on WPCOM
  • Run through commands in this documentation to cancel the plan via the API

Changelog entery

  • We improved the documentation for partners so they're now able to get them right on the Jetpack's Github repository under the docs/partners directory.

@ebinnion ebinnion force-pushed the add/jps-v2-api-direct-docs branch from e8b4149 to 52403ea Compare February 19, 2018 22:12
@ebinnion ebinnion requested a review from gravityrail February 19, 2018 22:23
@ebinnion ebinnion added [Status] Needs Review This PR is ready for review. and removed [Status] In Progress labels Feb 19, 2018
#### Response Parameters

- __success__: (bool) Was the operation successful?.
- __error_code__: (string) Error code, if any'.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks like this quote is not intended. There's one in the next line too.

Copy link
Copy Markdown
Contributor

@oskosk oskosk left a comment

Choose a reason for hiding this comment

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

LGTM!

@oskosk oskosk added [Status] Ready to Merge Go ahead, you can push that green button! and removed [Status] Needs Review This PR is ready for review. labels Feb 20, 2018
@ebinnion
Copy link
Copy Markdown
Contributor Author

Thanks! I've pushed a commit to remove those quotations.

Copy link
Copy Markdown
Contributor

@gravityrail gravityrail left a comment

Choose a reason for hiding this comment

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

Looking good! Just a couple of minor stylistic changes.


When you become a Jetpack partner, we will provide you with your partner ID and a secret key. Typically you just pass these values directly in to the `bin/partner-provision.sh` and `bin/partner_cancel.sh` scripts. But, when calling the WordPress.com API directly, you'll first need to get an access token with for your partner ID with a scope of `jetpack-partner`.

To do that, you'll make a `POST` request to the `https://public-api.wordpress.com/oauth2/token` endpoint passing with the request parameters mentioned below.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It's probably worth linking to https://developer.wordpress.com/docs/oauth2/ here for more information.

--url https://public-api.wordpress.com/oauth2/token \
--header 'cache-control: no-cache' \
--header 'content-type: multipart/form-data;' \
--form client_id={PARTNER_ID} \
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is this intended to be shell-interpolated? If so, it should probably be written as ${PARTNER_ID} or $PARTNER_ID

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Nope. I just meant it as a placeholder so the partner placed their ID there.

'content-type': 'multipart/form-data;'
},
formData: {
client_id: {PARTNER_ID},
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is also not valid JSON (it should be obvious to most people, but still could be a cause of confusion), so maybe declare these as a const above with dummy values and reference them as real variables.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

👍

client_id: {PARTNER_ID},
client_secret: {PARTNER_SECRET},
grant_type: 'client_credentials',
scope: 'jetpack-partner'
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Extra spaces


### Cancelling a plan

Cancelling a Jetpack for a given Jetpack site, as long as the partner making the cancellation request is also the partner that provisioned that plan, is fairly straightforward. To move forward, you'll need your partner secret as well as the URL of the site that you'd like to cancel the plan for.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Cancelling a Jetpack plan

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is also awkward wording in general, a bit longer than it needs to be. Maybe something like:

Plans can be cancelled by making a request using your Partner Token and the URL of the site being cancelled.

- __Method__: POST
- __URL__: https://public-api.wordpress.com/rest/v1.3/jpphp/{$site}/partner-cancel

`$site` is the site's domain and path where `/` in the path is replaced with `::`. For example:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Maybe include an example with two slashes as well, like

example.com/demo/wp becomes example.com::demo::wp


```shell
curl --request POST \
--url https://public-api.wordpress.com/rest/v1.3/jpphp/{SITE_DOMAIN}/partner-cancel \
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Interpolation tweaks as per comment above


var options = {
method: 'POST',
url: 'https://public-api.wordpress.com/rest/v1.3/jpphp/{SITE_DOMAIN}/partner-cancel',
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Interpolation tweaks as per comment above

@ebinnion ebinnion dismissed gravityrail’s stale review February 20, 2018 18:47

Feedback has been addressed

Copy link
Copy Markdown
Contributor

@gravityrail gravityrail left a comment

Choose a reason for hiding this comment

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

Great! Thanks for the changes. 👍

@oskosk oskosk merged commit 38dea65 into master Feb 20, 2018
@oskosk oskosk deleted the add/jps-v2-api-direct-docs branch February 20, 2018 19:19
oskosk added a commit that referenced this pull request Feb 27, 2018
oskosk added a commit that referenced this pull request Feb 27, 2018
* update changelog.txt

* Update readme.txt with scaffolding for 5.9 changelog and release draft shortlink

* Add changelog entry for #8243

* Add changelog entry for #8296

* Add changelog entry for #8367

* Add changelog entry for #8686

* Add changelog entry for #8707

* Add changelog entry for #8709 and #8714

* Add changelog entry for #8729

* Add changelog entry for #8777

* Add changelog entry for #8780

* Add changelog entry for #8786

* Add changelog entry for #8787

* Add changelog entry for #8801 #8805 #8832 #8865 and #8804

* Add changelog entry for #8817

* Add changelog entry for #8822

* Add changelog entry for #8823

* Add changelog entry for #8829

* Add changelog entry for #8834

* move some items to major enhancements

* Add changelog entry for #8836

* Add changelog entry for #8839

* Add changelog entry for #8861

* Add changelog entry for #8862

* Add changelog entry for #8863

* Add changelog entry for #8866

* Add changelog entry for #8870

* Add changelog entry for #8874

* Add changelog entry for #8875

* Add changelog entry for #8881

* Add changelog entry for #8890

* Add changelog entry for #8911

* Add changelog entry for #8927

* Add changelog entry for #8931

* Add changelog entry for #8933

* Add changelog entry for #8930

* fix wording

* typo

* minor fixes

* replace partner scripts for Jetpack Start in changelog entry

* Update to-test.md

* Update to-test.md

* minor style fixes to to-test.md

* minor style fixes to to-test.md

* minor fixes on to-test.md

* Add changelog entry for #8868

* Add changelog entry for #8844

* Add changelog entry for #8664

* Add changelog entry for #8935

* Add changelog entry for #8425

* Add changelog entry for #8625
@kraftbj kraftbj removed the [Status] Ready to Merge Go ahead, you can push that green button! label Oct 13, 2020
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.

6 participants