expertlead / webflow-php-sdk

PHP SDK for the Webflow CMS API
https://packagist.org/packages/expertlead/webflow-php-sdk
MIT License
24 stars 14 forks source link

[V2 Api] Basic changes required for api v2 to work #19

Open tobya opened 1 month ago

tobya commented 1 month ago

This is a first go at a V2 upgrade of the library. @wivern-co-uk

This is the basic changes I needed to make to ensure that the V2 api works with my code. There may be things in the existing code that are broken that I have missed as my code doesnt touch them.

I have put some comments in the code on things that I am looking for feedback on (feedback on anything else is also welcomed)

Updates

Basically I have made the following updates

Issues

{
  id: 12345abcdef
  name: 'this is the name'
  otherfields : 'otehr fields'
}

now the structure is

{
  id: 12345abcdef
fieldData: {
  name: 'this is the name'
  otherfields : 'otehr fields'
}
}

Setup

In order to use the V2 library you simply need to go to webflow and generate a new V2 api key and use that.

User will need to make some changes to their own code in structure and field names.

Changes

Some notes on what moving to V2 means for people with codebases. These are notes based on my experience and probably not comprehensive.

https://docs.developers.webflow.com/data/changelog/webflow-api-changed-endpoints

Field Names

Methods

Retrieving Items

$webflow->itemsAll($collectionId);
$webflow->item($collectionId, $itemId);

now return a differnt structure. Meta data is at the top level and the fields are one level below in a fieldData property. This will require changes to client code.

Publish Site

Publish site used to require that you passed an array containing a sub array 'domains' this has now changed and it just requires the user to pass a list of domain strings or domain ids

Publish Item

This is a new api end point for V2 and allows items in collections to be published without publishing the entire site.

wivern-co-uk commented 1 month ago

Thanks for filing a PR @tobya

What you think is missed to remove Draft status?

However I'll manage to check it only at the end of next week.

tobya commented 1 month ago

I think most of the basic changes are there. I would like someone else to test it a little :)

I have only used it for my requirements so there may be stuff missed.

tobya commented 1 month ago

Webflow support replied to me in reference to the sitepublish issue so I'll test out that fix and push.

tobya commented 1 month ago

@wivern-co-uk I'm using this now in my own code to connect via Webflow Api V2 and it seems to be working fine. So it can probably be merged.

Any additional testing by you or other users would be good.

wivern-co-uk commented 1 month ago

Any additional testing by you or other users would be good.

Sounds good, I'll let you know once there is a feedback on testing.

tobya commented 1 month ago

This seems to be working fine on my project on v2 so you can merge it if you wish to see if anyone else is looking for v2 support.