Code Monkey home page Code Monkey logo

create-api-gem's Introduction

Create API Gem

Build Status


(WARNING: THIS GEM HAS BEEN DEPRECATED)


Welcome to the Create API Gem! This gem provides a way of interacting with Typeforms Create API if you are programming in Ruby. We have created object representations of forms, themes, images, and workspaces so you can programmatically create all of the afore mentioned using Ruby nice and easily. Also you'll find all the requests needed to perform CRUD operations on each of these entities.

Getting Started

So before using the gem we recommend familiarizing yourself a little bit with our API. You can check out our Get-Started documentation.

You will also need a Personal Access Token if you want to see anything you make with this gem appear in your Typeform account.

Once you have this token, we recommend for security reasons saving it as an TYPEFORM_API_TOKEN environment variable. Also it will save you writing some code later on, if you don't want to do this just yet it is still possible to use the gem, but as we say - it is recommended.

Installation

Add this line to your application's Gemfile:

gem 'create_api_gem', git: 'https://github.com/Typeform/create-api-gem.git'

And then execute:

bundle install

Wherever you use the gem, it is easiest to require it like so:

require 'bundler'
Bundler.require

This should require all the gems in your Gemfile for you.

Usage

Now we're ready to develop. Let's say you want to create a form, you will just need to create a Form object and send it to our API's using a CreateFormRequest.

CreateFormRequest.execute(Form.new) - voila!

(We use .execute instead of .new on the CreateFormRequest to check that we get back the correct status code)

Note: This will only work if you have set the environment variable as mentioned before. You can explicitly pass a token like this

CreateFormRequest.execute(Form.new, token: 'your-token-goes-here')

If you check in your Typeform account you should have a form in there with a funny name. That's the one you just created! The funny name comes from this gem, as you can't create a form without a title. You'll probably want to decide your own title, you can do this like so

CreateFormRequest.execute(Form.new(title: 'My new form'), token: 'your-token-goes-here')

So we have create a form! Let's add some things to it. By assigning the result of the requests .form method we can receive a Form object to interact with

form = CreateFormRequest.execute(Form.new).form

Now we can add some blocks. Likewise with the form, if you simply call .new on a block, the gem will generate the bare minimum data required for that block. For example

form.blocks << ShortTextBlock.new

Now you're form has a block, but Typeform doesn't know that yet, so we need to send a request back to Typeform to update the form, again we can assign the result back to our original variable.

form = UpdateFormRequest.execute(form).form

If you want to use an existing form of yours, you can do so like this

form = RetrieveFormRequest.execute(Form.new(id: 'your-form-id-goes-here')).form

You can find your form's ID on the end of the URL for the typeform.

Development

After checking out the repo, you can run rake console to load the gem using the interactive ruby console.

Appendix

Here are the links to the classes that you can use.

Forms

Requests

CreateFormRequest
RetrieveFormRequest
RetrieveAllFormsRequest
UpdateFormRequest
UpdateFormPatchRequest
HeadFormRequest
DeleteFormRequest

Elements

Form

DateBlock
DropdownBlock
EmailBlock
FileUploadBlock
GroupBlock
LegalBlock
LongTextBlock
MultipleChoiceBlock
NumberBlock
OpinionScaleBlock
PaymentBlock
PictureChoiceBlock
PhoneNumberBlock RatingBlock
ShortTextBlock
StatementBlock
WebsiteBlock
YesNoBlock

ThankYouScreen
WelcomeScreen

LogicJump
Calculation

Settings
Notifications
Variables
Messages

Images

Requests

CreateImageRequest
CreateImageFromUrlRequest
RetrieveImageRequest
RetrieveAllImagesRequest
DeleteImageRequest

Elements

Image

Themes

Requests

CreateThemeRequest
RetrieveThemeRequest
RetrieveAllThemesRequest
UpdateThemeRequest
DeleteThemeRequest

Elements

Theme Background

Workspaces

CreateWorkspaceRequest
RetrieveWorkspaceRequest
RetrieveAllWorkspacesRequest
RetrieveDefaultWorkspaceRequest
UpdateWorkspaceRequest
DeleteWorkspaceRequest

Elements

Workspace

Code of Conduct

See our code of conduct here

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/Typeform/create-api-gem.

When writing Ruby code we use Rubocop as a static code analyzer. You can run rubocop from the route folder to make sure that your code fits the conventions we have set inside the '.rubocop.yml' file.

Versioning

We follow the semantic versioning as defined by rubygems.org

Alternatives

This is just a Ruby wrapper for our API's, they use the JSON format so they are extremely flexible. There are many alternatives!

Check out our developers documentation at developers.typeform.com

Legal

Copyright 2017 Typeform SL. under the Apache 2 License; see the LICENSE file for more information.

This is not an official Typeform product.

create-api-gem's People

Contributors

aitkenster avatar albarin avatar epallerols avatar forrest-ua avatar gerardabello avatar gpanagiotakop avatar jordiponsllaurado avatar kristofers91 avatar levboyarskiy avatar lhoeg avatar lluft avatar mathio avatar pchiwan avatar picsoung avatar raquelgs avatar scabfos avatar seti-tf avatar sevki avatar tb0hdan avatar tf-scott avatar thisiserico avatar vrybas avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

create-api-gem's Issues

Add more tests

  • Workspaces
  • Teams
  • More granular within form (e.g. logic_jump same method)
  • All request have a test

Tests not passing

Can't get the tests passing, even running with

TYPEFORM_API_TOKEN="<my token>" rake test

Tests with actual requests fail, can't understand why (some do, because it creates a workspace in my Typeform admin):

Failure:
Typeform::WorkspacesTest#test_all_requests [/home/mic/dev/articule/create-api-gem/test/test_workspaces.rb:37]:
Expected: false
  Actual: true

Tried changing the email in test_base.rb, no luck.

This gem is not safe to use in production

Hi I would like to highlight that this Gem is not safe to use in production.

The Typeform team keeps changing their API in production without any heads up and without anyone from the Typeform team adapting the Gem for these changes. The result is that this Gem will break in production and you will have unexpected downtime. This has been flagged to the Typeform team and it has happened 3 times since July without any change in behavior see:

Pull Request 74
Pull Request 79
Pull Request 80

Writing requests

Hello, could you help me write write the complete correct requests for creating questions inside a form, creating forms inside specific worskspace and also accessing responses.
I really tried finding out how, it took me a whole day as am a beginner in ror.
Thank you advance.

Plans to update?

What is the status of this gem?

Will it be updated with new features such as new picture position options?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.