Sha256: c334f14d63c64ab8926eed0d1a355fb1c972e587e80c4953d36ca63c56ad5082

Contents?: true

Size: 954 Bytes

Versions: 2

Compression:

Stored size: 954 Bytes

Contents

require 'pry'

access_token = 'access token'
organization = 'organization id'

require 'contentful/management'

client = Contentful::Management::Client.new(access_token)
space = Contentful::Management::Space.create(name: 'MySpace', organization_id: organization)

p space.content_types

type1 = space.content_types.create(name: 'ContentType 1')

p space.content_types.all

field = Contentful::Management::Field.new
field.id = 'such_content'
field.name = 'Such Content'
field.type = 'Text' #content types maybe as symbol?

type2 = space.content_types.new
type2.name = 'ContentType 2'
type2.fields = [field]
type2.save

field2 = Contentful::Management::Field.new
field2.id = 'wow_content'
field2.name = 'Wow Content'
field2.type = 'Location' #content types maybe as symbol?

type2.update(name: 'whoat', fields: [field, field2])

type2.fields.add(field2)

type2.activate
p type2.active?
type2.deactivate

type1.destroy

# clean up afterwards!
space.destroy

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
contentful-management-0.2.0 examples/content_types.rb
contentful-management-0.1.0 examples/content_types.rb