Class: GSVersionApiProvider

Inherits:
Object
  • Object
show all
Defined in:
lib/fastlane/plugin/gs_versioning/helper/gs_version_api_provider.rb

Constant Summary collapse

@@client =
Spaceship::GSBotClient.new

Class Method Summary collapse

Class Method Details

.getVersionsObject



101
102
103
104
105
106
107
108
109
110
111
112
113
# File 'lib/fastlane/plugin/gs_versioning/helper/gs_version_api_provider.rb', line 101

def self.getVersions()
  url = 'versions?platform=ios'
  response = @@client.request(:get) do |req|
    req.url url
    req.headers['Content-Type'] = 'application/json'
  end

  if response.success?
    GSVersionValue.parseBackendResponse(response.body)
  else
    raise(@@client.class.hostname + url + ' ' + response.status.to_s + ' ' + response.body['message'])
  end
end

.updateVersions(projectName, newValue = ) ⇒ Object



115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
# File 'lib/fastlane/plugin/gs_versioning/helper/gs_version_api_provider.rb', line 115

def self.updateVersions(projectName, newValue = GSVersionValue.versions_dict[projectName])
  require 'json'
  GSVersionValue.versions_dict[projectName] = newValue
  url = 'versions'
  json_params = {
      'alias' => projectName,
      'betaVersionName' => newValue['beta'],
      'rcVersionName' => newValue['rc'],
      'releaseVersionName' => newValue['release']
  }
  response = @@client.request(:patch) do |req|
    req.url url
    req.body = json_params.to_json
    req.headers['Content-Type'] = 'application/json'
  end

  if response.success?
    return response
  else
    raise(@@client.class.hostname + url + ' ' + response.status.to_s + ' ' + response.body['message'])
  end
end