Class: GdsApi::PublishingApiV2

Inherits:
Base
  • Object
show all
Defined in:
lib/gds_api/publishing_api_v2.rb

Instance Attribute Summary

Attributes inherited from Base

#options

Instance Method Summary collapse

Methods inherited from Base

#client, #create_client, #get_list!, #initialize, #url_for_slug

Constructor Details

This class inherits a constructor from GdsApi::Base

Instance Method Details

#discard_draft(content_id, options = {}) ⇒ Object



30
31
32
33
34
35
36
37
38
39
# File 'lib/gds_api/publishing_api_v2.rb', line 30

def discard_draft(content_id, options = {})
  optional_keys = [
    :locale,
    :previous_version,
  ]

  params = merge_optional_keys({}, options, optional_keys)

  post_json!(discard_url(content_id), params)
end

#get_content(content_id, options = {}) ⇒ Object



8
9
10
11
12
13
# File 'lib/gds_api/publishing_api_v2.rb', line 8

def get_content(content_id, options = {})
  params = {}
  params = params.merge(locale: options[:locale]) if options[:locale]

  get_json(content_url(content_id, params))
end

#get_content_items(params) ⇒ Object



55
56
57
58
# File 'lib/gds_api/publishing_api_v2.rb', line 55

def get_content_items(params)
  query = query_string(params)
  get_json("#{endpoint}/v2/content#{query}")
end

#get_linked_items(content_id, params = {}) ⇒ Object



60
61
62
63
# File 'lib/gds_api/publishing_api_v2.rb', line 60

def get_linked_items(content_id, params = {})
  query = query_string(params)
  get_json("#{endpoint}/v2/linked/#{content_id}#{query}")
end


41
42
43
# File 'lib/gds_api/publishing_api_v2.rb', line 41

def get_links(content_id)
  get_json(links_url(content_id))
end

#publish(content_id, update_type, options = {}) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/gds_api/publishing_api_v2.rb', line 15

def publish(content_id, update_type, options = {})
  params = {
    update_type: update_type
  }

  optional_keys = [
    :locale,
    :previous_version,
  ]

  params = merge_optional_keys(params, options, optional_keys)

  post_json!(publish_url(content_id), params)
end

#put_content(content_id, payload) ⇒ Object



4
5
6
# File 'lib/gds_api/publishing_api_v2.rb', line 4

def put_content(content_id, payload)
  put_json!(content_url(content_id), payload)
end


45
46
47
48
49
50
51
52
53
# File 'lib/gds_api/publishing_api_v2.rb', line 45

def put_links(content_id, payload)
  params = {
    links: payload.fetch(:links)
  }

  params = merge_optional_keys(params, payload, [:previous_version])

  put_json!(links_url(content_id), params)
end