Class: Apadmi::Grout::ConfluencePage

Inherits:
Struct
  • Object
show all
Defined in:
lib/apadmi/grout/models/confluence_page.rb

Overview

A model representing a Confluence page

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#author_idObject

Returns the value of attribute author_id

Returns:

  • (Object)

    the current value of author_id



22
23
24
# File 'lib/apadmi/grout/models/confluence_page.rb', line 22

def author_id
  @author_id
end

#bodyObject

Returns the value of attribute body

Returns:

  • (Object)

    the current value of body



22
23
24
# File 'lib/apadmi/grout/models/confluence_page.rb', line 22

def body
  @body
end

#created_atObject

Returns the value of attribute created_at

Returns:

  • (Object)

    the current value of created_at



22
23
24
# File 'lib/apadmi/grout/models/confluence_page.rb', line 22

def created_at
  @created_at
end

#idObject

Returns the value of attribute id

Returns:

  • (Object)

    the current value of id



22
23
24
# File 'lib/apadmi/grout/models/confluence_page.rb', line 22

def id
  @id
end

#last_owner_idObject

Returns the value of attribute last_owner_id

Returns:

  • (Object)

    the current value of last_owner_id



22
23
24
# File 'lib/apadmi/grout/models/confluence_page.rb', line 22

def last_owner_id
  @last_owner_id
end

Returns the value of attribute links

Returns:

  • (Object)

    the current value of links



22
23
24
# File 'lib/apadmi/grout/models/confluence_page.rb', line 22

def links
  @links
end

#owner_idObject

Returns the value of attribute owner_id

Returns:

  • (Object)

    the current value of owner_id



22
23
24
# File 'lib/apadmi/grout/models/confluence_page.rb', line 22

def owner_id
  @owner_id
end

#page_contentsObject

Returns the value of attribute page_contents

Returns:

  • (Object)

    the current value of page_contents



22
23
24
# File 'lib/apadmi/grout/models/confluence_page.rb', line 22

def page_contents
  @page_contents
end

#parent_idObject

Returns the value of attribute parent_id

Returns:

  • (Object)

    the current value of parent_id



22
23
24
# File 'lib/apadmi/grout/models/confluence_page.rb', line 22

def parent_id
  @parent_id
end

#parent_typeObject

Returns the value of attribute parent_type

Returns:

  • (Object)

    the current value of parent_type



22
23
24
# File 'lib/apadmi/grout/models/confluence_page.rb', line 22

def parent_type
  @parent_type
end

#positionObject

Returns the value of attribute position

Returns:

  • (Object)

    the current value of position



22
23
24
# File 'lib/apadmi/grout/models/confluence_page.rb', line 22

def position
  @position
end

#rawObject

Returns the value of attribute raw

Returns:

  • (Object)

    the current value of raw



22
23
24
# File 'lib/apadmi/grout/models/confluence_page.rb', line 22

def raw
  @raw
end

#space_idObject

Returns the value of attribute space_id

Returns:

  • (Object)

    the current value of space_id



22
23
24
# File 'lib/apadmi/grout/models/confluence_page.rb', line 22

def space_id
  @space_id
end

#statusObject

Returns the value of attribute status

Returns:

  • (Object)

    the current value of status



22
23
24
# File 'lib/apadmi/grout/models/confluence_page.rb', line 22

def status
  @status
end

#titleObject

Returns the value of attribute title

Returns:

  • (Object)

    the current value of title



22
23
24
# File 'lib/apadmi/grout/models/confluence_page.rb', line 22

def title
  @title
end

#urlObject

Returns the value of attribute url

Returns:

  • (Object)

    the current value of url



22
23
24
# File 'lib/apadmi/grout/models/confluence_page.rb', line 22

def url
  @url
end

#versionObject

Returns the value of attribute version

Returns:

  • (Object)

    the current value of version



22
23
24
# File 'lib/apadmi/grout/models/confluence_page.rb', line 22

def version
  @version
end

Class Method Details

.from_hash(hash, base_url = nil) ⇒ Apadmi::Grout::ConfluencePage

Parameters:

  • hash (Hash)
  • base_url (String, nil) (defaults to: nil)

Returns:



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/apadmi/grout/models/confluence_page.rb', line 46

def self.from_hash(hash, base_url = nil)
  space_id = hash["spaceId"] || hash.dig("space", "id")
  parent_id = hash["parentId"] || hash.dig("ancestors", -1, "id")

  base = base_url || hash.dig("_links", "base")
  webui = hash.dig("_links", "webui")
  url = base && webui ? base + webui : nil

  page_contents = hash.dig("body", "value") || hash.dig("body", "storage", "value")

  ConfluencePage.new(
    hash["id"],
    hash["title"],
    hash["version"],
    space_id,
    parent_id,
    hash["parentType"],
    hash["ownerId"],
    hash["lastOwnerId"],
    hash["createdAt"],
    hash["authorId"],
    hash["position"],
    hash["body"],
    hash["status"],
    hash["_links"],
    url,
    page_contents,
    hash
  )
end