README.md in rubyflare-0.1.0 vs README.md in rubyflare-0.2.0

- old
+ new

@@ -1,6 +1,6 @@ -[![Code Climate](https://codeclimate.com/github/trev/rubyflare/badges/gpa.svg)](https://codeclimate.com/github/trev/rubyflare) [![Test Coverage](https://codeclimate.com/github/trev/rubyflare/badges/coverage.svg)](https://codeclimate.com/github/trev/rubyflare/coverage) [![Build Status](https://travis-ci.org/trev/rubyflare.svg?branch=master)](https://travis-ci.org/trev/rubyflare) +[![Gem Version](https://badge.fury.io/rb/rubyflare.svg)](https://badge.fury.io/rb/rubyflare) [![Code Climate](https://codeclimate.com/github/trev/rubyflare/badges/gpa.svg)](https://codeclimate.com/github/trev/rubyflare) [![Test Coverage](https://codeclimate.com/github/trev/rubyflare/badges/coverage.svg)](https://codeclimate.com/github/trev/rubyflare/coverage) [![Build Status](https://travis-ci.org/trev/rubyflare.svg?branch=master)](https://travis-ci.org/trev/rubyflare) # Rubyflare Super thin Ruby wrapper for Cloudflare's V4 API. ## Installation @@ -19,41 +19,92 @@ $ gem install rubyflare ## Usage -First off, open https://api.cloudflare.com/ to see all the availble endpoints +First off, open https://api.cloudflare.com/ to see all the available endpoints ### Quick start +#### Setup connection + ``` require 'rubyflare' connection = Rubyflare.connect_with('bear@dog.com', 'supersecretapikey') - - # Get your user account details +``` + +#### GET your user account details + +``` user = connection.get('user') - # Get the result + # Read the first result p user.result - # Get your first name + # Read your first name p user.result[:first_name] +``` - # Create a new zone (domain) +#### Update(PATCH) your user account + +``` + user = connection.patch('user', { first_name: 'Bear' }) + + # Read the first result + p user.result +``` + +#### GET all your zones + +``` + zones = connection.get('zones') + + # Read the first zone + p zones.result + + # Read the array of zones. Pluralize #result + p zones.results +``` + +#### Create(POST) a new zone (domain) + +``` zone = connection.post('zones', { name: 'supercooldomain.com' }) # Check it out p zone.result +``` - # Want more details? Pluralize #result - p zones.results +#### Add(POST) an A Record to the zone - # Catch errors +``` + dns_record = connection.post('zones/{#zone.result[:id]}/dns_records', { + type: 'A", + name: 'supercooldomain.com', + content: '127.0.0.1' + }) + + # Check it out + p dns_record.result +``` + +#### DELETE a zone + +``` + deleted_zone = connection.delete('zones/#{zone.result[:id]}') + + # Check out the response + p deleted_zone +``` + +#### Catch errors + +``` begin connection.get('user') rescue => e - # Inspect this for more details + # Inspect e.reponse for more details p e.response end ``` ## Development