Class: WCC::Contentful::SimpleClient::Management
- Inherits:
-
WCC::Contentful::SimpleClient
- Object
- WCC::Contentful::SimpleClient
- WCC::Contentful::SimpleClient::Management
- Defined in:
- lib/wcc/contentful/simple_client/management.rb
Constant Summary
Constants inherited from WCC::Contentful::SimpleClient
Instance Attribute Summary
Attributes inherited from WCC::Contentful::SimpleClient
Instance Method Summary collapse
- #client_type ⇒ Object
- #content_types(**query) ⇒ Object
-
#initialize(space:, management_token:, **options) ⇒ Management
constructor
A new instance of Management.
- #post(path, body) ⇒ Object
-
#post_webhook_definition(webhook) ⇒ Object
{ “name”: “My webhook”, “url”: “www.example.com/test”, “topics”: [ “Entry.create”, “ContentType.create”, “*.publish”, “Asset.*” ], “httpBasicUsername”: “yolo”, “httpBasicPassword”: “yolo”, “headers”: [ { “key”: “header1”, “value”: “value1” }, { “key”: “header2”, “value”: “value2” } ] }.
- #webhook_definitions(**query) ⇒ Object
Methods inherited from WCC::Contentful::SimpleClient
Constructor Details
#initialize(space:, management_token:, **options) ⇒ Management
Returns a new instance of Management.
5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/wcc/contentful/simple_client/management.rb', line 5 def initialize(space:, management_token:, **) super( api_url: [:api_url] || 'https://api.contentful.com', space: space, access_token: management_token, ** ) @post_adapter = @adapter if @adapter.respond_to?(:post) @post_adapter ||= self.class.load_adapter(nil) end |
Instance Method Details
#client_type ⇒ Object
17 18 19 |
# File 'lib/wcc/contentful/simple_client/management.rb', line 17 def client_type 'management' end |
#content_types(**query) ⇒ Object
21 22 23 24 |
# File 'lib/wcc/contentful/simple_client/management.rb', line 21 def content_types(**query) resp = get('content_types', query) resp.assert_ok! end |
#post(path, body) ⇒ Object
58 59 60 61 62 63 64 |
# File 'lib/wcc/contentful/simple_client/management.rb', line 58 def post(path, body) url = URI.join(@api_url, path) Response.new(self, { url: url, body: body }, post_http(url, body)) end |
#post_webhook_definition(webhook) ⇒ Object
{
"name": "My webhook",
"url": "https://www.example.com/test",
"topics": [
"Entry.create",
"ContentType.create",
"*.publish",
"Asset.*"
],
"httpBasicUsername": "yolo",
"httpBasicPassword": "yolo",
"headers": [
{
"key": "header1",
"value": "value1"
},
{
"key": "header2",
"value": "value2"
}
]
}
53 54 55 56 |
# File 'lib/wcc/contentful/simple_client/management.rb', line 53 def post_webhook_definition(webhook) resp = post("/spaces/#{space}/webhook_definitions", webhook) resp.assert_ok! end |
#webhook_definitions(**query) ⇒ Object
26 27 28 29 |
# File 'lib/wcc/contentful/simple_client/management.rb', line 26 def webhook_definitions(**query) resp = get("/spaces/#{space}/webhook_definitions", query) resp.assert_ok! end |