Class: AppStoreDevApi::Request::Builder::Create

Inherits:
Object
  • Object
show all
Defined in:
lib/app_store_dev_api/request/builder/create.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type, properties, version = 'v1') ⇒ Create

Returns a new instance of Create.



35
36
37
38
39
40
41
# File 'lib/app_store_dev_api/request/builder/create.rb', line 35

def initialize(type, properties, version = 'v1')
  @name = type.singularize.classify
  @name = name
  @type = type
  @properties = properties
  @version = version
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



26
27
28
# File 'lib/app_store_dev_api/request/builder/create.rb', line 26

def name
  @name
end

#propertiesObject (readonly)

Returns the value of attribute properties.



26
27
28
# File 'lib/app_store_dev_api/request/builder/create.rb', line 26

def properties
  @properties
end

#typeObject (readonly)

Returns the value of attribute type.



26
27
28
# File 'lib/app_store_dev_api/request/builder/create.rb', line 26

def type
  @type
end

Class Method Details

.from(schema) ⇒ Object



28
29
30
31
32
33
# File 'lib/app_store_dev_api/request/builder/create.rb', line 28

def self.from(schema)
  type = schema.properties['data']['properties']['type']['enum'][0]
  properties = schema.properties['data']['properties']['attributes']['properties'].keys

  new(type, properties)
end

Instance Method Details

#aliasObject



55
56
57
# File 'lib/app_store_dev_api/request/builder/create.rb', line 55

def alias
  "create_#{@type.underscore.singularize}"
end

#http_methodObject



63
64
65
# File 'lib/app_store_dev_api/request/builder/create.rb', line 63

def http_method
  'post'
end

#sourceObject



43
44
45
46
47
48
49
50
51
52
53
# File 'lib/app_store_dev_api/request/builder/create.rb', line 43

def source
  @source ||= begin
    require 'erb'

    erb = ERB.new(TEMPLATE, trim_mode: '%<>-')

    erb.result(binding)
  end

  @source
end

#urlObject



59
60
61
# File 'lib/app_store_dev_api/request/builder/create.rb', line 59

def url
  "https://api.appstoreconnect.apple.com/#{@version}/#{@type}"
end