microcms #
microCMS sdk for v
microCMS sdk for v language.
repo: https://github.com/zztkm/microcms-v-sdk
Installation and Import
Using vpm
Install / Update module:
v install zztkm.microcms
Import
import zztkm.microcms
Directly from GitHub
v install --git https://github.com/zztkm/microcms-v-sdk
Usage
TODO: 使い方をがんばって記載する
NOTE
Until the following bugs are fixed, please be careful with structure definitions during create and update. Zero values are also included in Body.
[omitempty]
for strings causes compilation error
APIs
Content API
- GET /api/v1/{endpoint}
- GET /api/v1/{endpoint}/{content_id}
- POST /api/v1/{endpoint}
- PUT /api/v1/{endpoint}/{content_id}
- PATCH /api/v1/{endpoint}/{content_id}
- DELETE /api/v1/{endpoint}/{content_id}
Management API
fn new #
fn new(service_domain string, api_key string) Client
new returns a new microcms client.
fn (Client) content #
fn (c Client) content<T>(p GetContentParams) ?T
content is a method to retrieve a single content.
The retrieved content is stored in the type parameter T and returned.
fn (Client) content_list #
fn (c Client) content_list<T>(p GetContentListParams) ?T
content_list is a method to retrieve a content list.
The retrieved content is stored in the type parameter T and returned.
fn (Client) content_list_str #
fn (c Client) content_list_str(p GetContentListParams) ?string
content_list is a method to retrieve a content list.
If you want to decode your own, use this one.
fn (Client) content_meta_list #
fn (c Client) content_meta_list<T>(p ListParams) ?T
fn (Client) content_str #
fn (c Client) content_str(p GetContentParams) ?string
content_str is a method to retrieve a single content.
If you want to decode your own, use this one.
fn (Client) create_content #
fn (c Client) create_content<T>(p CreateParams, data T) ?CreateResponse
create_content is a method to create content.
It sends an http request with data as the body.
fn (Client) delete_content #
fn (c Client) delete_content(p DeleteParams) ?
delete_content is a method to delete content.
fn (Client) update_content #
fn (c Client) update_content<T>(p UpdateParams, data T) ?UpdateResponse
update_content is a method to update content.
It sends an http request with data as the body.
struct CreateParams #
struct CreateParams {
pub mut:
endpoint string
content_id string
status string
}
CreateParams holds information for creating content.
Note: It does not hold the content itself.
struct CreateResponse #
struct CreateResponse {
pub:
id string
}
CreateResponse holds the response body of a successful microCMS content creation.
struct DeleteParams #
struct DeleteParams {
pub mut:
endpoint string
content_id string
}
DeleteParams holds information for deleting content.
struct GetContentListParams #
struct GetContentListParams {
pub mut:
endpoint string
draft_key string
limit int
offset int
orders []string
q string
fields []string
ids []string
filters string
depth int
rich_editor_format string
}
GetContentListParams holds information for retrieve the content list.
struct GetContentParams #
struct GetContentParams {
pub mut:
endpoint string
content_id string
draft_key string
fields []string
depth int
rich_editor_format string
}
GetContentParams holds information for retrieve a single content.
struct UpdateParams #
struct UpdateParams {
pub mut:
endpoint string
content_id string
}
UpdateParams holds information for updating content.
Note: It does not hold the content itself.
struct UpdateResponse #
struct UpdateResponse {
pub:
id string
}
UpdateResponse holds the response body of a successful microCMS content update.