Class: AppleVPP::Request

Inherits:
Object
  • Object
show all
Defined in:
lib/apple_vpp/request.rb

Class Method Summary collapse

Class Method Details

.submit(url, s_token = nil, body = {}) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/apple_vpp/request.rb', line 7

def self.submit( url, s_token = nil, body = {} )
  body['sToken'] = s_token
  body.delete_if { |_k, v| v.nil? }
  
  resp = RestClient.post url, body, content_type: :json
  json = JSON.parse(resp)

  if json['status'] == -1
    raise (eval "AppleVPP::Error::Code#{json['errorNumber']}"), json['errorMessage'] 
  end

  json
end