Module: AlumniStories

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

Instance Method Summary collapse

Methods included from BaseClient

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

Instance Method Details

#update_alum_story_sort_order(id, direction = 'down') ⇒ AlumniStory

Change the sort order of an alumni story.

Examples:

Update an alumni story sort order

Spartacus#update_alum_story_sort_order(1, {name: 'Real Cool Checkpoint'})

13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/client/alumni_stories.rb', line 13

def update_alum_story_sort_order(id, direction='down')
  accepted_params = ['up', 'down', :up, :down]
  if accepted_params.include?(direction)

    url = "#{@api_base_path}/alum_stories/#{id}/update_sort_order"

    handle_timeouts do
      response = self.class.put(url,
                                 headers: auth_header,
                                 body: { direction: direction })
      convert_response(response, "alumni_story")
    end
  else
    raise InvalidDirectionError
  end
end