Skip to content

Commit

Permalink
Add server move IP support
Browse files Browse the repository at this point in the history
  • Loading branch information
jpalumickas committed Jan 4, 2017
1 parent 7365ffd commit df9a8f6
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 0 deletions.
17 changes: 17 additions & 0 deletions lib/ivapi/client/server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,23 @@ def ptr(options = {})
get('/json.php', params)
end

# Moves additional IP to another server.
#
# ip - The String of additional IP.
# target_id - The String of another server id.
#
# Returns the Hash with information.
def move_ip(ip, target_id)
params = {
command: 'server_move_ip',
id: server_id,
ip: ip,
target_id: target_id
}

get('/json.php', params)
end

# Send command to change server plan.
#
# options - The Hash options (default: {}):
Expand Down
4 changes: 4 additions & 0 deletions spec/fixtures/server_move_ip.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"ip": "1.2.3.4",
"target_id": 123
}
12 changes: 12 additions & 0 deletions spec/ivapi/client/server_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,18 @@
end
end

describe '#move_ip' do
let(:move_ip) { Ivapi.server.move_ip('1.2.3.4', 123) }
before do
stub_command('server_move_ip', id: 3, ip: '1.2.3.4', target_id: 123)
.to_return(json_response('server_move_ip.json'))
end

it 'has correct ip address' do
expect(move_ip.ip).to eq('1.2.3.4')
end
end

describe 'change server plan' do
before(:each) do
stub_command('server_change', id: 3)
Expand Down

0 comments on commit df9a8f6

Please sign in to comment.