{"action":"created","issue":{"url":"https://api.github.com/repos/amro/gibbon/issues/120","labels_url":"https://api.github.com/repos/amro/gibbon/issues/120/labels{/name}","comments_url":"https://api.github.com/repos/amro/gibbon/issues/120/comments","events_url":"https://api.github.com/repos/amro/gibbon/issues/120/events","html_url":"https://github.com/amro/gibbon/pull/120","id":86107692,"number":120,"title":"Streaming export API","user":{"login":"fsluis","id":6199431,"avatar_url":"https://avatars.githubusercontent.com/u/6199431?v=3","gravatar_id":"","url":"https://api.github.com/users/fsluis","html_url":"https://github.com/fsluis","followers_url":"https://api.github.com/users/fsluis/followers","following_url":"https://api.github.com/users/fsluis/following{/other_user}","gists_url":"https://api.github.com/users/fsluis/gists{/gist_id}","starred_url":"https://api.github.com/users/fsluis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fsluis/subscriptions","organizations_url":"https://api.github.com/users/fsluis/orgs","repos_url":"https://api.github.com/users/fsluis/repos","events_url":"https://api.github.com/users/fsluis/events{/privacy}","received_events_url":"https://api.github.com/users/fsluis/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":8,"created_at":"2015-06-08T09:47:07Z","updated_at":"2015-06-29T12:48:20Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/amro/gibbon/pulls/120","html_url":"https://github.com/amro/gibbon/pull/120","diff_url":"https://github.com/amro/gibbon/pull/120.diff","patch_url":"https://github.com/amro/gibbon/pull/120.patch"},"body":"# About this fork / pull request\r\n\r\n\r\n## Why this fork?\r\nThe export wrapper of the Mailchimp API wrapper \"Gibbon\" loads all the exported data first in memory, before returning it. Since with exporting data, there can be lots and lots of data, this seemed fairly inefficient. This fork solves this.\r\n\r\n## How is this fork different?\r\nThe changes are as following:\r\n* Instead of httparty, the basic net::http interface is used to stream data directly from the Mailchimp API.\r\n* The export API functions now require a &block to feed each row of data to.\r\n* The export test functions use webmock to fake and verify net::http requests.\r\n* Some re-arrangement of functions (parse_response at APICategory.rb)\r\n\r\n## What can I do with this fork?\r\nAll you can do with the normal Gibbon API Wrapper. Plus, parsing each row of exported data while it is being received from the export API:\r\n```\r\n    ge = Gibbon::Export.new(\"your_api_key\")\r\n    ge.list({:id => *list_id*}) { |row| *do_sth_with* row }\r\n```\r\n\r\nIt is important to supply an explicit block / procedure to the export functions, not an implicit one. So, the preceding and following one will work. Please note this method also includes a counter (*i*, starting at 0) telling which row of data you're receiving:\r\n```\r\n    method = Proc.new do |row, i|\r\n        *do_sth_with* row\r\n    end\r\n    ge.list(params, &method)\r\n```\r\n\r\nPlease note, the following example gives a block that is outside of the function and therefore **won't** work:\r\n```\r\n    ge.list({:id => *list_id*}) do |row|\r\n        *do_sth_with* row\r\n    end\r\n```\r\n\r\nAnd, the original way of working with gibbon is still functional of course:\r\n```\r\n    list = ge.list({:id => *list_id*})\r\n```\r\n\r\n## Some final words\r\nHappy coding!\r\n"},"comment":{"url":"https://api.github.com/repos/amro/gibbon/issues/comments/116645918","html_url":"https://github.com/amro/gibbon/pull/120#issuecomment-116645918","issue_url":"https://api.github.com/repos/amro/gibbon/issues/120","id":116645918,"user":{"login":"amro","id":16900,"avatar_url":"https://avatars.githubusercontent.com/u/16900?v=3","gravatar_id":"","url":"https://api.github.com/users/amro","html_url":"https://github.com/amro","followers_url":"https://api.github.com/users/amro/followers","following_url":"https://api.github.com/users/amro/following{/other_user}","gists_url":"https://api.github.com/users/amro/gists{/gist_id}","starred_url":"https://api.github.com/users/amro/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/amro/subscriptions","organizations_url":"https://api.github.com/users/amro/orgs","repos_url":"https://api.github.com/users/amro/repos","events_url":"https://api.github.com/users/amro/events{/privacy}","received_events_url":"https://api.github.com/users/amro/received_events","type":"User","site_admin":false},"created_at":"2015-06-29T12:48:20Z","updated_at":"2015-06-29T12:48:20Z","body":"NP, thanks for contributing"}}