Class: Contentful::Management::TaxonomyConcept

Inherits:
Object
  • Object
show all
Includes:
Resource, Resource::Refresher, Resource::SystemProperties
Defined in:
lib/contentful/management/taxonomy_concept.rb

Overview

Instance Attribute Summary

Attributes included from Resource::SystemProperties

#sys

Attributes included from Resource

#client, #properties, #raw_object, #request

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Resource::Refresher

#reload

Methods included from Resource

#array?, #default_locale, #environment_id, #fields, #nested_locale_fields?, #resource?, #save, #sys

Class Method Details

.all(client, organization_id, query = {}) ⇒ Object



47
48
49
50
# File 'lib/contentful/management/taxonomy_concept.rb', line 47

def self.all(client, organization_id, query = {})
  requester = ResourceRequester.new(client, self)
  requester.all({ organization_id: organization_id }, query)
end

.create(client, organization_id, attributes) ⇒ Object



62
63
64
65
66
67
68
69
70
71
# File 'lib/contentful/management/taxonomy_concept.rb', line 62

def self.create(client, organization_id, attributes)
  requester = ResourceRequester.new(client, self)
  requester.create(
    {
      organization_id: organization_id,
      id: attributes[:id]
    }.compact,
    attributes
  )
end

.find(client, organization_id, concept_id) ⇒ Contentful::Management::TaxonomyConcept

Finds a Taxonomy Concept by ID.

Parameters:

Returns:



39
40
41
42
43
44
45
# File 'lib/contentful/management/taxonomy_concept.rb', line 39

def self.find(client, organization_id, concept_id)
  requester = ResourceRequester.new(client, self)
  requester.find(
    id: concept_id,
    organization_id: organization_id
  )
end

.total(client, organization_id) ⇒ Object



52
53
54
55
56
57
58
59
60
# File 'lib/contentful/management/taxonomy_concept.rb', line 52

def self.total(client, organization_id)
  response = client.get(
    Request.new(
      client,
      build_endpoint(total: true, organization_id: organization_id)
    )
  )
  response.object['total']
end

Instance Method Details

#ancestors(query = {}) ⇒ Object



105
106
107
108
109
110
111
112
113
# File 'lib/contentful/management/taxonomy_concept.rb', line 105

def ancestors(query = {})
  requester = ResourceRequester.new(client, self.class)
  endpoint_options = {
    organization_id: sys[:organization].id,
    id: id,
    ancestors: true
  }
  requester.all(endpoint_options, query)
end

#descendants(query = {}) ⇒ Object



115
116
117
118
119
120
121
122
123
# File 'lib/contentful/management/taxonomy_concept.rb', line 115

def descendants(query = {})
  requester = ResourceRequester.new(client, self.class)
  endpoint_options = {
    organization_id: sys[:organization].id,
    id: id,
    descendants: true
  }
  requester.all(endpoint_options, query)
end

#destroyObject



93
94
95
96
97
98
99
100
101
102
103
# File 'lib/contentful/management/taxonomy_concept.rb', line 93

def destroy
  requester = ResourceRequester.new(client, self.class)
  requester.destroy(
    {
      organization_id: sys[:organization].id,
      id: id
    },
    {},
    { 'X-contentful-version' => sys[:version].to_s }
  )
end

#update(patch_operations) ⇒ Object



78
79
80
81
82
83
84
85
86
87
88
89
90
91
# File 'lib/contentful/management/taxonomy_concept.rb', line 78

def update(patch_operations)
  requester = ResourceRequester.new(client, self.class)
  requester.patch(
    {
      organization_id: sys[:organization].id,
      id: id
    },
    patch_operations,
    {
      'Content-Type' => 'application/json-patch+json',
      'X-Contentful-Version' => sys[:version].to_s
    }
  )
end