Module: Roadmaps

Includes:
BaseClient
Included in:
Spartacus
Defined in:
lib/client/roadmaps.rb

Instance Method Summary collapse

Methods included from BaseClient

#auth_header, #convert_keys, #convert_response, #handle_timeouts, #success?, #whitelist_params

Instance Method Details

#get_roadmap(id) ⇒ Roadmap

Get a roadmap

Examples:

Get a roadmap

Spartacus#get_roadmap(1)

Parameters:

  • id (Integer)

    A roadmap id.

Returns:

  • (Roadmap)

    The roadmap.



12
13
14
15
16
17
18
19
# File 'lib/client/roadmaps.rb', line 12

def get_roadmap(id)
  url = "#{@api_base_path}/roadmaps/#{id}"

  handle_timeouts do
    response = self.class.get(url, headers: auth_header)
    convert_response(response, "roadmap")
  end
end

#get_sections_for_roadmap(id) ⇒ HTTParty::Response

Get a roadmap’s sections

Examples:

Get a roadmap’s sections

Spartacus#get_roadmap(1)

Parameters:

  • id (Integer)

    A roadmap id.

Returns:

  • (HTTParty::Response)

    The roadmap’s sections.



27
28
29
30
31
32
33
34
# File 'lib/client/roadmaps.rb', line 27

def get_sections_for_roadmap(id)
  url = "#{@api_base_path}/roadmaps/#{id}/sections"

  handle_timeouts do
    response = self.class.get(url, headers: auth_header)
    convert_response(response, "section")
  end
end

#update_roadmap(id, options = {}) ⇒ Roadmap

Update a roadmap

Examples:

Update a roadmap

Spartacus#update_roadmap(129, {name: 'Real Cool Roadmap'})

Parameters:

  • id (Integer)

    A roadmap id.

  • options (Hash) (defaults to: {})

    A customizable set of options.

Options Hash (options):

  • :name (String)

    Roadmap name.

  • :display_name (String)

    Roadmap display.

  • :version (Integer)

    Roadmap version.

  • :projects (Integer)

    Number of roadmap projects

Returns:

  • (Roadmap)

    The updated roadmap



47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/client/roadmaps.rb', line 47

def update_roadmap(id, options={})
  whitelist = ['name', 'display_name', 'version', 'projects']

  options = convert_keys(options)
  roadmap_params = whitelist_params(options, whitelist)
  url = "#{@api_base_path}/roadmaps/#{id}"

  handle_timeouts do
    response = self.class.put(url, headers: auth_header,
                              body: { roadmap: roadmap_params })
    convert_response(response, "roadmap")
  end
end