A set of libraries that make it easy to build an SDK gem on top of an HTTP web service.
Currently, only RESTful JSON services are supported.
classMyNotFoundError<StandardErrordefinitialize(response) super"object not found: #{response.body}"endendclassMyUnknownError<StandardError; endclassMyBaseClassincludeSimpleSDKBuilder::Baseconfig:service_url=>'https://api.davidmdawson.com'config:timeout=>15000config:error_handlers=> { '404'=>MyNotFoundError, '*'=>MyUnknownError } endclassMyResource<MyBaseClassincludeSimpleSDKBuilder::Resourcesimple_sdk_attribute:id, :name, :valueclass<<selfdefallresponse = json_request( :path=>"/my_resources" ) response.build(MyResource) enddeffind(id) response = json_request( :path=>"/my_resources/#{id}" ) response.build(MyResource) endenddefcreateresponse = json_request( :path=>"/my_resources", :method=>:post, :body=>self ) self.attributes = response.parsed_bodyselfenddefupdate(attrs) response = json_request( :path=>"/my_resources/#{id}", :method=>:put, :body=>attrs ) self.attributes = response.parsed_bodyselfenddefdestroyjson_request( :path=>"/my_resources/#{id}", :method=>:delete ) # leaves current object aloneendendall_resources = MyResource.allsome_resource = MyResource.find(1) new_resource = MyResource.new( :name=>'test', :value=>'this is a test' ).createnew_resource.update( :value=>'this test is almost done...' ) new_resource.destroy