Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Readme Driven API changes #4

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 22 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,33 +9,37 @@ The library currently just exposes the service endpoints and accepts unverified
## Instructions

```ruby

# Simple usage
results = Arcgis::Online.search(q: "weather", itemtype: "Web Map")
item = Arcgis::Online.item(id: 'd6b52a4540b747b09884d738b44a00d2')

# Create a client
@online = Arcgis::Online.new(:host => "http://www.arcgis.com/sharing/rest/")
# Do an unauthenticated search
results = @online.search(:q => "weather", :itemtype => "Web Map")
Arcgis::Online.login(host: "http://www.arcgis.com/sharing/rest/",
username: @username,
password: @password )
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want something like: Arcgis::Online.logged_in?


# For features with permissions, first log in
@online.login(:username => @username, :password => @password)
# Do an authenticated search
results = Arcgis::Online.search(q: "weather", itemtype: "Web Map")

# Create an item
response = @online.item_add( :title => "Weather Station Temperatures",
:type => "CSV",
:file => File.open("my_data.csv"),
:tags => %w{temperature stations}.join(","))
item = Arcgis::Online::Item.new( title: "Weather Station Temperatures",
type: "CSV",
file: File.open("my_data.csv"),
tags: %w{temperature stations}.join(","))

@id = response["id"]
puts "This item has #{response['numComments']} comments."
puts "This item has #{item.numComments]} comments."

# Publish as a feature service
analysis = @online.item_analyze(:id => @id, :type => "CSV")
publish = @online.item_publish(:id => @id,
:filetype => "Feature Service",
:publishParameters => analysis["publishParameters"].to_json)
# Publish as a feature service - returns a new item (yeah...)
service_item = item.publish(filetype: "Feature Service",
publishParameters: analysis["publishParameters"].to_json)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this line analysis is going to be nil -- I'm assuming we will also need a way to replace the @online.item_analyze method?

item.analyze(...)?


puts "Feature Service URL: " + publish["services"].first["serviceurl"]
puts "Feature Service URL: " + service_item.services.first.serviceUrl

# Clean up
@online.item_delete(:items => [@id, publish["services"].first["serviceItemId"]])
service_item.delete
item.delete

```

### Testing
Expand Down