Class: Assembla::Client::Spaces

Inherits:
API
  • Object
show all
Defined in:
lib/assembla_api/client/spaces.rb

Defined Under Namespace

Classes: Documents, Milestones, SpaceTools, Ssh, StandupAwayReports, StandupReports, Tags, Tickets, UserRoles, Users, Webhooks, WikiPages

Constant Summary collapse

VALID_PARAMS_NAMES =
%w[
  name
  wiki_name
  description
  public_permissions
  team_permissions
  watcher_permissions
  share_permissions
  status
  team_tab_role
  default_showpage
  tabs_order
  banner
  banner_height
  banner_text
  banner_link
  style
  approved
  can_join
  wiki_format
].freeze
VALID_REQUEST_PARAM_VALUES =
{
  'status' => [0, 1, 2, 3, 4],
  'team_tab_role' => [0, 10, 50, 90],
  'public_permissions' => [0, 1],
  'team_permissions' => [1, 2, 3],
  'watcher_permissions' => [0, 1],
}

Constants included from MimeType

MimeType::MEDIA_LOOKUP

Constants included from Assembla::Constants

Assembla::Constants::ACCEPT, Assembla::Constants::ACCEPTED_OAUTH_SCOPES, Assembla::Constants::ACCEPT_CHARSET, Assembla::Constants::CACHE_CONTROL, Assembla::Constants::CONTENT_LENGTH, Assembla::Constants::CONTENT_TYPE, Assembla::Constants::DATE, Assembla::Constants::ETAG, Assembla::Constants::HEADER_LAST, Assembla::Constants::HEADER_LINK, Assembla::Constants::HEADER_NEXT, Assembla::Constants::LOCATION, Assembla::Constants::META_FIRST, Assembla::Constants::META_LAST, Assembla::Constants::META_NEXT, Assembla::Constants::META_PREV, Assembla::Constants::META_REL, Assembla::Constants::OAUTH_SCOPES, Assembla::Constants::PARAM_PAGE, Assembla::Constants::PARAM_PER_PAGE, Assembla::Constants::PARAM_START_PAGE, Assembla::Constants::RATELIMIT_LIMIT, Assembla::Constants::RATELIMIT_REMAINING, Assembla::Constants::SERVER, Assembla::Constants::USER_AGENT

Instance Attribute Summary

Attributes inherited from API

#current_options

Attributes included from Authorization

#scopes

Instance Method Summary collapse

Methods inherited from API

after_callbacks, after_request, #api_methods_in, #arguments, before_callbacks, before_request, clear_request_methods!, #execute, extend_with_actions, extra_methods, extract_class_name, #filter_callbacks, inherited, #initialize, internal_methods, method_added, #method_missing, #module_methods_in, namespace, #process_basic_auth, request_methods, root!, #run_callbacks, #set, #setup, #with, #yield_or_eval

Methods included from Assembla::ClassMethods

#configuration, #configure, #require_all

Methods included from RateLimit

#ratelimit, #ratelimit_remaining, #ratelimit_reset

Methods included from Request::Verbs

#delete_request, #get_request, #head_request, #options_request, #patch_request, #post_request, #put_request

Methods included from MimeType

#lookup_media, #parse

Methods included from Authorization

#auth_code, #authenticated?, #authentication, #authorize_url, #basic_authed?, #client, #get_token

Constructor Details

This class inherits a constructor from Assembla::API

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Assembla::API

Instance Method Details

#copy(*args) ⇒ Object



92
93
94
95
96
97
98
99
100
# File 'lib/assembla_api/client/spaces.rb', line 92

def copy(*args)
  arguments(args, required: [:space]) do
    permit VALID_PARAMS_NAMES
    assert_required %w[ name ]
    assert_values VALID_REQUEST_PARAM_VALUES
  end

  post_request("/spaces/#{arguments.space}/copy", arguments.params)
end

#create(*args) ⇒ Object



82
83
84
85
86
87
88
89
90
# File 'lib/assembla_api/client/spaces.rb', line 82

def create(*args)
  arguments(args) do
    permit VALID_PARAMS_NAMES
    assert_required %w[ name ]
    assert_values VALID_REQUEST_PARAM_VALUES
  end

  post_request("/spaces", arguments.params)
end

#delete(*args) ⇒ Object Also known as: remove

Delete a space

Deleting a space requires owner access.

Examples:

assembla = Assembla.new oauth_token: '...'
assembla.repos.delete 'space-name'


111
112
113
114
# File 'lib/assembla_api/client/spaces.rb', line 111

def delete(*args)
  arguments(args, required: [:space])
  delete_request("/spaces/#{arguments.space}", arguments.params)
end

#edit(*args) ⇒ Object

Edit a space

Examples:

assembla = Assembla.new
assembla.spaces.edit 'space-name',
  name: 'hello-world',
  description: 'This is your first space'

Parameters:



131
132
133
134
135
136
137
138
# File 'lib/assembla_api/client/spaces.rb', line 131

def edit(*args)
  arguments(args,required: [:space]) do
    permit VALID_PARAMS_NAMES
    assert_values VALID_REQUEST_PARAM_VALUES
  end

  put_request("/spaces/#{arguments.space}", arguments.params)
end

#get(*args) ⇒ Object Also known as: find

api.spaces.get space: ‘breakout’



76
77
78
79
# File 'lib/assembla_api/client/spaces.rb', line 76

def get(*args)
  arguments(args, required: [:space])
  get_request("/spaces/#{arguments.space}", arguments.params)
end

#my(*args) ⇒ Object



68
69
70
71
72
73
# File 'lib/assembla_api/client/spaces.rb', line 68

def my(*args)
  arguments(args)
  response = get_request("/spaces", arguments.params)
  return response unless block_given?
  response.each { |el| yield el }
end