Module: RubyLokaliseApi::Rest::Branches

Included in:
RubyLokaliseApi::Rest
Defined in:
lib/ruby_lokalise_api/rest/branches.rb

Instance Method Summary collapse

Instance Method Details

#branch(project_id, branch_id) ⇒ RubyLokaliseApi::Resources::Branch

Returns a single branch

Parameters:

  • project_id (String)
  • branch_id (String, Integer)

Returns:

See Also:



27
28
29
30
31
32
33
# File 'lib/ruby_lokalise_api/rest/branches.rb', line 27

def branch(project_id, branch_id)
  params = { query: [project_id, branch_id] }

  data = endpoint(name: 'Branches', params: params).do_get

  resource 'Branch', data
end

#branches(project_id, req_params = {}) ⇒ RubyLokaliseApi::Collections::Branches

Returns project branches

Parameters:

  • project_id (String)
  • req_params (Hash) (defaults to: {})

Returns:

See Also:



12
13
14
15
16
17
18
19
# File 'lib/ruby_lokalise_api/rest/branches.rb', line 12

def branches(project_id, req_params = {})
  name = 'Branches'
  params = { query: project_id, req: req_params }

  data = endpoint(name: name, params: params).do_get

  collection name, data
end

#create_branch(project_id, req_params) ⇒ RubyLokaliseApi::Resources::Branch

Creates a branch

Parameters:

  • project_id (String)
  • req_params (Hash)

Returns:

See Also:



41
42
43
44
45
46
47
# File 'lib/ruby_lokalise_api/rest/branches.rb', line 41

def create_branch(project_id, req_params)
  params = { query: project_id, req: req_params }

  data = endpoint(name: 'Branches', params: params).do_post

  resource 'Branch', data
end

#destroy_branch(project_id, branch_id) ⇒ RubyLokaliseApi::Generics::DeletedResource

Deletes a branch

Parameters:

  • project_id (String)
  • branch_id (String, Integer)

Returns:

See Also:



70
71
72
73
74
75
76
# File 'lib/ruby_lokalise_api/rest/branches.rb', line 70

def destroy_branch(project_id, branch_id)
  params = { query: [project_id, branch_id] }

  data = endpoint(name: 'Branches', params: params).do_delete

  RubyLokaliseApi::Generics::DeletedResource.new data.content
end

#merge_branch(project_id, branch_id, req_params) ⇒ RubyLokaliseApi::Generics::MergedBranches

Merges two branches

Parameters:

  • project_id (String)
  • branch_id (String, Integer)
  • req_params (Hash)

Returns:

See Also:



85
86
87
88
89
90
91
# File 'lib/ruby_lokalise_api/rest/branches.rb', line 85

def merge_branch(project_id, branch_id, req_params)
  params = { query: [project_id, branch_id, :merge], req: req_params }

  data = endpoint(name: 'Branches', params: params).do_post

  RubyLokaliseApi::Generics::MergedBranches.new data.content
end

#update_branch(project_id, branch_id, req_params = {}) ⇒ RubyLokaliseApi::Resources::Branch

Updates a branch

Parameters:

  • project_id (String)
  • branch_id (String, Integer)
  • req_params (Hash) (defaults to: {})

Returns:

See Also:



56
57
58
59
60
61
62
# File 'lib/ruby_lokalise_api/rest/branches.rb', line 56

def update_branch(project_id, branch_id, req_params = {})
  params = { query: [project_id, branch_id], req: req_params }

  data = endpoint(name: 'Branches', params: params).do_put

  resource 'Branch', data
end